#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<cstring>
#include<deque>
#define itn int
#define coder goodboy
using namespace std;
typedef long long LL;typedef unsigned long long ULL;
const int maxn=1000010;
int n,m,room[maxn],cnt[maxn],l[maxn],r[maxn],d[maxn];
inline void in(){
freopen("classrooms.in","r",stdin);
freopen("classrooms.out","w",stdout);
scanf("%d%d",&n,&m);
for (int i=1;i<=n;i++){
scanf("%d",&room[i]);
}
for (int i=1;i<=m;i++){
scanf("%d%d%d",&d[i],&l[i],&r[i]);
cnt[l[i]]+=d[i];
cnt[r[i]+1]-=d[i];
}
}
inline void deal(){
int c=m,ans=0;
for (int i=1;i<=n;i++){
ans+=cnt[i];
while(c>=1&&ans>room[i]){
if (i>=l[c]&&i<=r[c]) ans-=d[c];
cnt[l[c]]-=d[c];
cnt[r[c]+1]+=d[c];
c--;
}
}
if (c==m){
printf("0\n");
}
else printf("-1\n%d",++c);
}
int Main(){
in();
deal();
return 0;
}
int main(){;}
int goodboy=Main();