SDE Path

Delete Node at Given Position

Easy

Delete Node at Given Position

Delete the node at a given position from a singly linked list.

Input format

The first line contains N and POS (0 ≤ POS < N). The second line contains the N node values.

Output format

Delete the node at 0-based position POS and print the resulting list (print -1 if it becomes empty).

Constraints

  • Values fit in a 64-bit signed integer
  • Trailing whitespace and a trailing newline are ignored by the judge

Read from stdin, write to stdout. Sample cases below show the exact format.

Sample cases

Example 1
Input
4 2
1 2 3 4
Expected output
1 2 4
Example 2
Input
1 0
7
Expected output
-1