import itertools import sys import copy import math N = int(input()) K = int(input()) lsn = [int(input()) for i in range(N)] if N==K: print(max(lsn)-min(lsn)) sys.exit() lsp = itertools.combinations_with_replacement(range(K),N) ans = 0 for p in lsp: lsg2 = [[] for i in range(K)] for i in range(N): lsg2[p[i]].append(lsn[i]) maxa = 0 mina = 10000 f = True for i in range(K): if len(lsg2[i]) == 0: f= False break maxa = max(maxa,sum(lsg2[i])/len(lsg2[i])) mina = min(mina,sum(lsg2[i])/len(lsg2[i])) if f: ans = max(ans,math.ceil(maxa-mina)) print(ans)