n,k=map(int,input().split()) a=list(map(int,input().split())) tmp=[0] for i in a: tmp=sorted(tmp+[j-i for j in tmp])[:k] print(-tmp[-1])