#include <bits/stdc++.h>
using namespace std;
char pan[10][10];
int main() {
  std::ios::sync_with_stdio(false);
  long long n, m;
  cin >> n >> m;
  vector<long long> v(n + 1), pre(n + 1, 0);
  for (long long i = 1; i <= n; i++) {
    cin >> v[i];
    pre[i] = pre[i - 1] + v[i];
  }
  long long ans = 0;
  long long val = 0;
  while (m--) {
    long long l, r;
    cin >> l >> r;
    long long sum = pre[r] - pre[l - 1];
    if (sum < 0) {
      continue;
    }
    val += sum;
    ans = max(ans, val);
  }
  cout << ans;
}
