#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long LL; const int MR=1e6+10; int n,Q,a[MR]; LL S,sa[MR],sb[MR],sc[MR]; int main(){ cin>>n>>Q; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++){ sa[i]=sa[i-1]+a[i]; sb[i]=sb[i-1]+1ll*a[i]*(a[i]+1)/2; } for(int i=1;i>S; if(S>sb[n]){ printf("-1\n"); continue; } int i=lower_bound(sb+1,sb+1+n,S)-sb; int j=lower_bound(sc+1,sc+MR,S-sb[i-1])-sc; printf("%lld\n",sa[i-1]+j); } return 0; }