#include <bits/stdc++.h>
using namespace std;
int n, m;
int dp[101];
int a[101], l[101], r[101];
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
  }
  for (int i = 1; i <= m; ++i) {
    cin >> l[i] >> r[i];
  }
  dp[0] = 0;
  int ret = 0;
  for (int i = 1; i <= m; ++i) {
    int update = 0;
    for (int k = l[i]; k <= r[i]; ++k) {
      update += a[k];
    }
    for (int j = i - 1; j >= 0; --j) {
      dp[i] = max(dp[i], dp[j] + update);
    }
    ret = max(ret, dp[i]);
  }
  cout << ret << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  solve();
  return 0;
}
