Under construction

Still being built. Things may change

Selection of Participants of an Experiment

Time limit2sMemory limit512 MB

Summary
Given a list of student scores, find the smallest absolute difference between any two of them.
Level

Easy3 of 10

Topics
Sorting, Array
Solved
No attempts yet

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 nn, an integer with 2≤n≤10002 \le n \le 1000. The second line holds the scores of the nn students. The score aia_i (1≤i≤n)(1 \le i \le n) of the ii-th student is a non-negative integer not greater than 1,000,0001{,}000{,}000.

A line containing a single 00 marks the end of the input. The sum of nn over all datasets is at most 50,00050{,}000.

Output

For each dataset, pick the two students whose scores differ the least and print the absolute value of that difference on one line.

Examples4

  1. Example 1

    Input
    5
    10 10 10 10 10
    5
    1 5 8 9 11
    7
    11 34 83 47 59 29 70
    0
    
    Expected output
    0
    1
    5
    
  2. Example 2

    Input
    2
    0 1000000
    0
    
    Expected output
    1000000
    
  3. Example 3

    Input
    2
    1000000 1000000
    0
    
    Expected output
    0
    
  4. Example 4

    Input
    6
    1000000 3 999999 500 4 800000
    0
    
    Expected output
    1