#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const ll INF=1LL<<60; typedef pair P; typedef pair PP; const ll MOD=1e9+7; int main(){ int N,Q; cin>>N>>Q; vector A(N); vector B; for(int i=0;i>A[i]; for(int j=1;j<=A[i];j++){ B.push_back(j); } } int n=B.size(); vector sumB(n); sumB[0]=B[0]; for(int i=1;i>S; auto it=lower_bound(sumB.begin(),sumB.end(),S); if(it==sumB.end()){ cout<<-1<