#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  vector<int> arr{0}, sum{0}, subs;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    arr.emplace_back(k);
    sum.emplace_back(sum.back() + k);
  }
  for (int i = 0; i < m; ++i) {
    int l, r;
    cin >> l >> r;
    subs.emplace_back(sum[r] - sum[l - 1]);
  }
  vector<int> dp(m, 0);
  for (int i = 0; i < m; ++i) {
    dp[i] = max(subs[i], 0);
    for (int j = 0; j < i; ++j) {
      dp[i] = max(dp[i], dp[j] + subs[i]);
    }
  }
  cout << max(0, *max_element(dp.begin(), dp.end())) << endl;
  return 0;
}
