#include <bits/stdc++.h>
long long int mood[105], dp[105][105];
struct node {
  long long int l, r;
} ar[105];
int main() {
  long long int n, m, i, j, ans = 0, k, temp;
  scanf("%lld%lld", &n, &m);
  std::map<long long int, long long int> m1;
  for (i = 1; i <= n; i++) {
    scanf("%lld", &mood[i]);
  }
  for (i = 1; i <= m; i++) {
    scanf("%lld%lld", &ar[i].l, &ar[i].r);
    for (j = ar[i].l; j <= ar[i].r; j++) {
      dp[j][0]++;
      dp[j][dp[j][0]] = i;
    }
  }
  for (i = 1; i <= n; i++) {
    ans += (dp[i][0]) * mood[i];
  }
  for (i = 1; i <= n; i++) {
    if (mood[i] < 0) {
      for (j = 1; j <= dp[i][0]; j++) {
        temp = 0;
        if (m1.find(dp[i][j]) == m1.end()) {
          for (k = ar[dp[i][j]].l; k <= ar[dp[i][j]].r; k++) {
            temp += mood[k];
          }
          if (ans - temp > ans) {
            ans -= temp;
            m1[dp[i][j]];
          }
        }
      }
    }
  }
  if (ans < 0)
    printf("0\n");
  else
    printf("%lld\n", ans);
  return 0;
}
