#include <bits/stdc++.h>
using namespace std;
const int MX = 1e3 + 10;
const double PI = acos(-1.0), EPS = 1e-9;
int N, p;
long long pref[MX], arr[MX];
long long s(int l, int r) {
  if (l > r) return 0;
  if (l == 0) return pref[r];
  return pref[r] - pref[l - 1];
}
int main() {
  cin >> N >> p;
  for (int i = 0; i < N; i++) cin >> arr[i];
  pref[0] = 0;
  for (int i = 0; i < N; i++) {
    if (i) pref[i] = pref[i - 1];
    pref[i] += arr[i];
  }
  long long mx = 0;
  for (int i = 0; i < p; i++) {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    mx += max(0LL, s(a - 1, b - 1));
  }
  cout << mx;
}
