#include <bits/stdc++.h>
using namespace std;
bool is_prime(long long x) {
  if (x == 1) return false;
  for (int i = 2; i * i <= x; i++)
    if (x % i == 0) return false;
  return true;
}
bool is_palindrome(string s1) {
  int l = s1.length();
  for (int i = 0; i < l / 2; i++)
    if (s1[i] != s1[l - i - 1]) return false;
  return true;
}
unsigned long long C(long long n, long long k) {
  if (k == 0) return 1;
  return (n * C(n - 1, k - 1)) / k;
}
long long modular_pow(long long base, long long exponent, int modulus) {
  long long result = 1;
  while (exponent > 0) {
    if (exponent % 2 == 1) result = (result * base) % modulus;
    exponent = exponent >> 1;
    base = (base * base) % modulus;
  }
  return result;
}
long long binaryToDec(string number) {
  long long result = 0, pow = 1;
  for (int i = number.length() - 1; i >= 0; --i, pow <<= 1)
    result = (result + (number[i] - '0') * pow) % 1000003;
  return result;
}
long long binaryToDec2(string number) {
  long long result = 0, pow = 1;
  int l = number.length();
  for (int i = 0; i < l; ++i, pow <<= 1)
    result = (result + (number[i] - '0') * pow) % 1000003;
  return result;
}
string decimalToBin(int number) {
  if (number == 0) return "0";
  if (number == 1) return "1";
  if (number % 2 == 0)
    return decimalToBin(number / 2) + "0";
  else
    return decimalToBin(number / 2) + "1";
}
unsigned long long GCD(unsigned long long a, unsigned long long b) {
  return b == 0 ? a : GCD(b, a % b);
}
int cntMask(int mask) {
  int ret = 0;
  while (mask) {
    if (mask % 2) ret++;
    mask /= 2;
  }
  return ret;
}
int getBit(int mask, int i) { return ((mask >> i) & 1) == 1; }
int setBit(int mask, int i, int value = 1) {
  return (value) ? mask | (1 << i) : (mask & ~(1 << i));
}
unsigned long long mystoi(string s) {
  unsigned long long ans = 0;
  unsigned long long po = 1;
  for (int i = s.length() - 1; i >= 0; i--) {
    ans += (s[i] - '0') * po;
    po *= 10;
  }
  return ans;
}
string conv(int i) {
  string t = "";
  while (i) {
    t += '0' + (i % 10);
    i /= 10;
  }
  return t;
}
bool hasZero(int i) {
  if (i == 0) return true;
  while (i) {
    if (i % 10 == 0) return true;
    i /= 10;
  }
  return false;
}
bool isSortedAc(int a[], int n) {
  for (int i = 0; i < int(n - 1); i++)
    if (a[i] > a[i + 1]) return false;
  return true;
}
bool isSortedDec(int a[], int n) {
  for (int i = 0; i < int(n - 1); i++)
    if (a[i] < a[i + 1]) return false;
  return true;
}
bool cmp(unsigned long long i, unsigned long long j) { return i > j; }
void count_quotes() {
  string s;
  int ans = 0;
  while (getline(cin, s) && s != "EOF") {
    if (s[0] == '-') ans++;
  }
  cout << ans << endl;
  return;
}
int n, a[100 + 5];
int m;
int memo[101];
int gg[102][102];
pair<int, int> subs[102];
int solve(int i) {
  if (i == m) return 0;
  int &ret = memo[i];
  if (ret != -2000000) return ret;
  ret = solve(i + 1);
  int c1 = 0;
  for (int k = 0; k < int(n); k++) {
    if (gg[k][i]) c1 += a[k];
  }
  return ret = max(ret, c1 + solve(i + 1));
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < int(n); i++) cin >> a[i];
  for (int i = 0; i < int(m); i++) cin >> subs[i].first >> subs[i].second;
  for (int i = 0; i < int(101); i++) memo[i] = -2000000;
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(m); j++) {
      if (i + 1 <= subs[j].second && i + 1 >= subs[j].first) gg[i][j] = 1;
    }
  int ans = solve(0);
  ans = max(ans, 0);
  cout << ans << endl;
  return 0;
}
