#include <stdio.h>
#include <stdlib.h>

int main()
{
	int input_n;
	int input_score_a[1000];
	int min_sa = 1000000, score_a_sa = 0;
	int counter_i, counter_j;
	
	for( ; ; )
	{
		scanf("%d", &input_n);
		if(input_n == 0)
			break;
		
		for(counter_i = 0 ; counter_i < input_n ; counter_i++)
			scanf("%d", &input_score_a[counter_i]);
		
		for(counter_i = 0 ; counter_i < input_n ; counter_i++)
		{
			for(counter_j = counter_i + 1 ; counter_j < input_n ; counter_j++)
			{
				score_a_sa = abs(input_score_a[counter_i] - input_score_a[counter_j]);
				if(min_sa > score_a_sa)
					min_sa = score_a_sa;
			}
		}
		
		printf("%d\n", min_sa);
		
		min_sa = 1000000;
	}
	return 0;
}

