# coding: utf-8 N = int(input()) K = int(input()) n = [int(input()) for __ in range(N)] print(max(n) - min(n))