#!/usr/bin/python # -*- coding: utf-8 -*- N = int(raw_input()) arr = sorted(set((map(int, raw_input().split())))) if len(arr) < 2: print "0" exit() ans = [] for i in xrange(0,len(arr) - 1): ans.append(arr[i+1] - arr[i]) print min(ans)