from copy import * n,k=map(int, input().split()) c=list(map(int, input().split())) C=[] for i in range(n): a=c[i];j=i;cost=0 b=copy(c) while set(b)!={0} and jn-1: up=n-1 if b[j]!=0 : cost+=c[j] b[lo:up]=[0 for i in b[lo:up]] C.append(cost) j+=1 print(min(C))