#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, ar[110], sum, nwsum, i, in1, in2, j;
  while (scanf("%d%d", &n, &m) == 2) {
    for (i = 1; i <= n; i++) {
      scanf("%d", &ar[i]);
    }
    sum = 0;
    for (i = 1; i <= m; i++) {
      scanf("%d%d", &in1, &in2);
      nwsum = sum;
      for (j = in1; j <= in2; j++) {
        nwsum += ar[j];
      }
      if (nwsum > sum) sum = nwsum;
    }
    printf("%d\n", sum);
  }
  return 0;
}
