#include #include #include int cmp(const void *a,const void *b){ if(*(int*)a>*(int*)b){return 1;} else if(*(int*)a<*(int*)b){return -1;} else {return 0;} } int main(void){ int l,n,w[10005]; scanf("%d",&l); scanf("%d",&n); for(int i=0;i=sum){break;} sum=sum+w[i]; } printf("%d\n",sum); }