#include #include using namespace std; #define ll long long #define ld long double const ll M = 1e9+7; int main() { ll n,m,ans=0,r=0;cin >> m >> n;vector arr(m); for (ll i = 0; i < m; i++)cin >> arr[i];sort(arr.begin(),arr.end()); while(n--){ ll cor,a,b;cin >> cor >> a >> b; ll it=lower_bound(arr.begin(),arr.end(),cor)-arr.begin(); if(arr[it]==cor)ans+=b; else if(it==0){ if(arr[it]-cor