N, X = int(input()), list(set(list(reversed(sorted(list(map(int, input().split()))))))) print(X[0] - X[1])