#include #define ll long long using namespace std; int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); ll n,m; cin>>n>>m; ll l[n+5],f[m+5],b[m+5],w[m+5]; l[0]=-1000000005; l[n+1]=1000000005; for(ll i=1;i<=n;i++)cin>>l[i]; for(ll i=1;i<=m;i++)cin>>f[i]>>b[i]>>w[i]; ll ans=0; for(ll i=1;i<=m;i++){ int left=1,right=n,mid; while(leftl[mid])mid++; ll tmp=max(w[i]-(l[mid]-f[i]),w[i]-(f[i]-l[mid-1])); tmp=max(tmp,b[i]); ans+=tmp; } } cout<