i=input N,K=int(i()),i() D=[int(i()) for _ in '1'*(N)] print(max(D)-min(D))