698. Remove Duplicates from Sorted Linked List

0

Easy

Given a sorted linked list, remove all nodes that have duplicate values, keeping only the distinct values from the original list. Return the updated linked list, which should also be sorted.

Input Format

The input consists of an integer n, representing the size of the linked list, followed by n integers representing the values of the nodes.

Output Format

Print the updated linked list. If there are no elements in the updated linked list, print -1 as a delimiter.

Example

Input

4 1 1 2 3

Output

2 3

Constraints

The number of nodes in the linked list is between 0 and 300, inclusive. Each node's value is an integer between -100 and 100. The linked list is guaranteed to be sorted in ascending order.
Loading...

View Submissions

Console