Selection of Participants of an Experiment
Time limit2sMemory limit512 MB
Given a list of student scores, find the smallest absolute difference between any two of them.
Problem
Dr. Tsukuba has devised a new method of programming training. To measure how well it works, he plans a control experiment. Two students take part: one trains under the conventional method and the other under his new method. Comparing the final scores of the two tells him whether the new method works.
The comparison is fair only when the two students have scores as close as possible. Dr. Tsukuba has the score list of every student who can join the experiment. Write a program that picks the two students whose scores differ the least.
Input
The input consists of several datasets, each in the following format.
n
a1 a2 … an
A dataset takes two lines. The first line holds the number of students , an integer with . The second line holds the scores of the students. The score of the -th student is a non-negative integer not greater than .
A line containing a single marks the end of the input. The sum of over all datasets is at most .
Output
For each dataset, pick the two students whose scores differ the least and print the absolute value of that difference on one line.