#include <bits/stdc++.h>   using namespace std;   const int INF = 0x7f7f7f7f;   int BigMod(long long int B, long long int P, long long int M) {     long long int R = 1;     while (P > 0) {       if (P % 2 == 1) R = (R * B) % M;       P /= 2;       B = (B * B) % M;     }     return (int)R;   }   long long int maxDivide(long long int a, long long int b) {     while (a % b == 0) a = a / b;     return a;   }   long long int isUgly(long long int no) {     no = maxDivide(no, 2);     no = maxDivide(no, 3);     no = maxDivide(no, 5);     return (no == 1) ? 1 : 0;   }   long long int myXOR(long long int x, long long int y) {     long long int res = 0;     for (long long int i = 31; i >= 0; i--) {       bool b1 = x & (1 << i);       bool b2 = y & (1 << i);       bool xoredBit = (b1 & b2) ? 0 : (b1 | b2);       res <<= 1;       res |= xoredBit;     }     return res;   }   long long int ar[110];   int main() {     long long int n, m, a, b, c, x, y;     cin >> n >> m;     x = 0;     for (long long int i = 1; i <= n; i++) {       cin >> ar[i];     }     y = 0;     for (long long int i = 1; i <= m; i++) {       cin >> a >> b;       x = 0;       for (long long int j = a; j <= b; j++) {         x += ar[j];       }       if (x > 0) y += x;     }     cout << y << endl;     return 0;   }   