#coding:utf-8 N=input() K=input() list=[int(raw_input()) for i in range(N)] print str(max(list)-min(list))