n = input() input() c = [input() for i in xrange(n)] print max(c)-min(c)