# -*- coding: utf-8 -*- import math n = int(input()) k = int(input()) n_box = [] for _ in range(n): n_box.append(int(input())) nbox_sort = sorted(n_box) nbox_min = (nbox_sort[0]) nbox_max = nbox_sort[-1] print(math.ceil(nbox_max - nbox_min))