N = input() x = map(int,raw_input().split()) D = list(set(x)) D.sort(reverse=True) print abs(D[0]-D[1])