A Sequence Problem

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Given a sequence of N integers, a, print the minimum value of |a_i - a_j| for some i, j (1 \le i, j \le N, i \ne j). In other words, find the minimum difference between any 2 integers in the sequence.

Note that |a| is the absolute value function.

Input Specification

The first line will contain the integer N (2 \le N \le 5 \times 10^4).

The second line will contain N integers, a_1, a_2, \ldots, a_N (0 \le a_i \le 10^9), the sequence of integers.

Output Specification

Print the minimum difference between any 2 integers in the sequence.

Sample Input

5
1 5 3 9 2

Sample Output

1

Explanation for Sample Input

The minimum difference is |1 - 2| = 1.


Comments

There are no comments at the moment.