#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7, inf = 1e9, N = 1e5 + 1;
const ll MOD = 1e9 + 7, INF = 1e19;
ld tic, tac;
int tc = 1;
ll n, m, u, v;
ll a[101];
ll lz[101], ans = 0;
void solve() {
  cin >> n >> m;
  for (int i = (1) - (1 - 2 * (1 > n + 1) < 0);
       (1 - 2 * (1 > n + 1)) > 0 ? i < (n + 1) : i >= (n + 1);
       i += (1 - 2 * (1 > n + 1))) {
    cin >> a[i];
    lz[i] += a[i];
  }
  for (int i = (0) - (1 - 2 * (0 > n) < 0);
       (1 - 2 * (0 > n)) > 0 ? i < (n) : i >= (n); i += (1 - 2 * (0 > n)))
    lz[i + 1] += lz[i];
  for (int i = (0) - (1 - 2 * (0 > m) < 0);
       (1 - 2 * (0 > m)) > 0 ? i < (m) : i >= (m); i += (1 - 2 * (0 > m))) {
    cin >> u >> v;
    ans += max(0ll, lz[v] - lz[u - 1]);
  }
  cout << ans << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  cout << fixed << setprecision(10);
  if (tc != 1) cin >> tc;
  for (int i = 1; i <= tc; ++i) {
    if (!1) cerr << "\nWhile solving TC " << i << ":\n", tic = clock();
    solve();
    if (!1)
      tac = clock(), cerr << "\nTC " << i << " done in:: "
                          << 1000 * (tac - tic) / CLOCKS_PER_SEC << " ms\n";
  }
  if (!1)
    cerr << "\nGG in: " << 1000 * ((ld)clock()) / CLOCKS_PER_SEC << " ms\n";
  return 0;
}
