# coding: utf-8 # Here your code ! N = int(input()) K = int(input()) array = [] for i in range(N): num = int(input()) array.append(num) A = max(array) B = min(array) print(A-B)