#include<bits/stdc++.h>
using namespace std;
long long l[1000000],x[1000000],r[1000000],c[100000],s[100000],b[100000],n,m;
bool chk(int ans){
memset(b,0,sizeof(b));
memset(s,0,sizeof(s));
int L,R,X;
for(int i=1;i<=m;i++){
L=l[i];
R=r[i];
X=x[i];
b[L]+=X;
b[R+1]-=X;
}
for(int i=1;i<=m;i++){
s[i]=s[i-1]+b[i];
if(s[i]>c[i])return true;
}
return false;
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>c[i];
}
for(int i=1;i<=m;i++){
cin>>l[i]>>r[i]>>x[i];
}
int l=1,r=m,ans=0;
while(l<=r){
int mid=(l+r)>>1;
if(chk(mid)){
ans=mid;
r=mid-1;
}else{
l=mid+1;
}
}
if(!ans){
cout<<"YES";
}else{
cout<<"NO"<<endl;
cout<<ans<<endl;
}
return 0;
}