#include <bits/stdc++.h>
using namespace std;
vector<int> a, l, r, fact, fact2;
int n, m, sum, sum_now, ans;
int main() {
  cin >> n >> m;
  a.resize(n + 1);
  fact.resize(n + 1);
  fact2.resize(n + 1);
  l.resize(m);
  r.resize(m);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> l[i] >> r[i];
  for (int i = 0; i < m; i++) {
    sum = 0;
    for (int x = 1; x <= n; x++) fact[x] = 0;
    for (int x = l[i]; x <= r[i]; x++) {
      fact[x]++;
      sum += a[x] * fact[x];
    }
    for (int j = i + 1; j < m; j++) {
      sum_now = 0;
      for (int x = l[j]; x <= r[j]; x++) {
        if (fact[x] != 0) sum_now -= a[x] * fact[x];
        fact[x]++;
        sum_now += a[x] * fact[x];
      }
      if (sum_now + sum >= sum) {
        sum += sum_now;
        continue;
      }
      for (int x = l[j]; x <= r[j]; x++) fact[x]--;
    }
    if (sum > ans) ans = sum;
  }
  cout << ans;
  return 0;
}
