#include <iostream>
#include <vector>
#include <algorithm>
#include <random>

using namespace std;
using ll = long long;

#define pII pair<Interval, Interval>

struct Interval {
    int l, r;

    pII middle() const {
        int m = (l + r) / 2;
        return {{l, m}, {m, r}};
    }
};

vector<int> tree, setx, a;

void build(int j, Interval i) {
    if (i.r - i.l == 1) {
        tree[j] = a[i.l];
        return;
    }
    pII mid = i.middle();

    build(2 * j + 1, mid.first);
    build(2 * j + 2, mid.second);

    tree[j] = tree[2 * j + 1] + tree[2 * j + 2];
}

void apply(int j, int v, Interval i) {
    tree[j] = v * (i.r - i.l);
    setx[j] = v;
}

void push(int j, Interval i) {
    if (setx[j] == -1) return;

    pII mid = i.middle();
    apply(2 * j + 1, setx[j], mid.first);
    apply(2 * j + 2, setx[j], mid.second);
    setx[j] = -1;
}

void mass_update(int j, Interval i, Interval si, int v) {
    if (si.l >= si.r) return;

    if (i.l == si.l and i.r == si.r) {
        apply(j, v, i);
        return;
    }
    push(j, i);

    pII mid = i.middle();
    pII sis = {
            {si.l, min(si.r, mid.first.r)},
            {max(si.l, mid.second.l), si.r},
    };

    mass_update(2 * j + 1, mid.first, sis.first, v);
    mass_update(2 * j + 2, mid.second, sis.second, v);

    tree[j] = tree[2 * j + 1] + tree[2 * j + 2];
}

int get_v(int j, Interval i, int si) {
    if (not (i.l <= si and si < i.r)) return 0;

    if (i.r - i.l == 1) {
        return tree[j];
    }
    push(j, i);

    pII mid = i.middle();

    return get_v(2 * j + 1, mid.first, si) + get_v(2 * j + 2, mid.second, si);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, q;
    cin >> n >> q;

    a.resize(n);
    tree.resize(n * 4);
    setx.resize(4 * n, -1);

    for (int i = 0; i < n; ++i)
        cin >> a[i];
    build(0, {0, n});

    int ti, tl, tr;
    for (int _ = 0; _ < q; ++_) {
        cin >> ti >> tl >> tr;
        ti--;
        tl--;

        if (get_v(0, {0, n}, ti) == 1) {
            mass_update(0, {0, n}, {tl, tr}, 1);
        }
    }

    cout << tree[0];
}