n,k=[int(input()) for i in range(2)] l=sorted(list(int(input()) for i in range(n))) if k > 2: print(round(l[-1]-l[0])) else: for i in range(1,n): a=l[:i] b=l[i:] print(b)