# -*- coding: utf-8 -*- N = input() K = input() A =[] for i in range(N): A.append(input()) print max(A) - min(A)