func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T gi() {     T f = 1, x = 0;     char c = getchar();     while (c <  0  || c >  9 ) {       if (c ==  - ) f = -1;       c = getchar();     }     while (c >=  0  && c <=  9 ) x = x * 10 + c -  0 , c = getchar();     return f * x;   }   const int INF = 0x3f3f3f3f, N = 200003, M = N << 1;   int n, m, c[N];   long long tr[N << 2], dp[N], lz[N << 2];   struct Node {     int l, p;   };   vector<Node> a[N];   inline int ls(int p) { return p << 1; }   inline int rs(int p) { return p << 1 | 1; }   inline void pushup(int p) { tr[p] = max(tr[ls(p)], tr[rs(p)]); }   inline void pushdown(int p) {     if (lz[p]) {       tr[ls(p)] += lz[p], lz[ls(p)] += lz[p];       tr[rs(p)] += lz[p], lz[rs(p)] += lz[p];       lz[p] = 0;     }   }   void modify(int ql, int qr, long long val, int l, int r, int p) {     if (ql <= l && r <= qr) {       tr[p] += val, lz[p] += val;       return;     }     pushdown(p);     int mid = (l + r) >> 1;     if (ql <= mid) modify(ql, qr, val, l, mid, ls(p));     if (qr > mid) modify(ql, qr, val, mid + 1, r, rs(p));     pushup(p);   }   long long query(int ql, int qr, int l, int r, int p) {     if (ql <= l && r <= qr) return tr[p];     int mid = (l + r) >> 1;     long long ans = 0;     if (ql <= mid) ans = query(ql, qr, l, mid, ls(p));     if (qr > mid) ans = max(ans, query(ql, qr, mid + 1, r, rs(p)));     return ans;   }   int main() {     n = gi<int>(), m = gi<int>();     for (int i = 1; i <= n; i += 1) c[i] = gi<int>();     while (m--) {       int l = gi<int>(), r = gi<int>(), p = gi<int>();       a[r].push_back((Node){l, p});     }     long long sum = 0, res = 0;     for (int i = 1; i <= n + 1; i += 1) {       res += c[i];       dp[i] = max(dp[i - 1], query(1, max(1, i - 1), 1, n, 1));       modify(1, i, -c[i], 1, n, 1);       for (auto x : a[i]) modify(1, x.l, x.p, 1, n, 1), sum += x.p;       dp[i] = max(dp[i], sum - res);       modify(i, i, dp[i - 1], 1, n, 1);     }     printf( %lld n , dp[n + 1]);     return 0;   }   