#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; //#include // using namespace atcoder; // using mint = modint; #define rep(i, n) for (int i = 0; i < n; i++) #define endl '\n' #define print(n) cout << (n) << endl #define ALL(a) (a).begin(), (a).end() int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, q__; cin >> n >> q__; vector a(n); rep(i, n) cin >> a[i]; for (int q_ = 0; q_ < q__; q_++) { int l, r; ll x; cin >> l >> r >> x; l--; long ans = 0; for (int i = l; i < r; i++) ans += min(a[i], x); cout << ans << endl; } }