#include <bits/stdc++.h>
using namespace std;
int arr[103][2];
int md[103];
bool tak[103];
int cnt[103];
int main(void) {
  int n, m, i, j, k, x, tmp, tmp2, ans = 0;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &md[i]);
  for (i = 1; i <= m; i++) scanf("%d %d", &arr[i][0], &arr[i][1]);
  for (i = 1; i <= m; i++) {
    x = 0;
    tmp = ans;
    for (j = 1; j <= m; j++) {
      if (tak[j]) continue;
      tmp2 = ans;
      for (k = arr[j][0]; k <= arr[j][1]; k++) {
        tmp2 += md[k];
      }
      if (tmp2 > tmp) {
        tmp = tmp2;
        x = j;
      }
    }
    ans = max(tmp, ans);
    tak[x] = 1;
    for (k = arr[x][0]; k <= arr[x][1]; k++) cnt[k]++;
  }
  printf("%d\n", ans);
  return 0;
}
