#include<stdio.h>
int main(){
  int n,a[1000],diff,i,j,mindiff;
  while(1){
    scanf("%d",&n);
    if(n==0)break;

    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
    }
    if(a[0]>a[1]){
      mindiff=a[0]-a[1];
    }else{
      mindiff=a[1]-a[0];
    }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	if(i==j)continue;
	
	diff=a[i]-a[j];

	if(diff>0 && mindiff > diff){
	  mindiff = diff;
	}
      }
    }
    printf("%d\n",mindiff);
  }
  return 0;
}