# -*- coding: utf-8 -*- n = int(input()) x = [int(i) for i in input().split()] u = list(set(x)) s = sorted(u) result = 0 if len(s) >= 2: result = min([s[i+1] - s[i] for i in range(len(s)-1)]) print(result)