# -*- coding: utf-8 -*- n = int(input()) k = input() number_list = [input() for i in range(n)] min_num = int(min(number_list)) max_num = int(max(number_list)) answer = max_num - min_num print(answer)