#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif
int n, m;
cin >> n >> m;
vector<int> v(n);
for (int &i : v) cin >> i;
ll ans = accumulate(v.begin(), v.end(), 0ll);
set<int> s;
sort(v.begin(), v.end());
for (int i = 0, a, b; i < m; ++i) {
cin >> a >> b;
s.insert(b);
}
for (auto &i : s) {
ans -= (n - (lower_bound(v.begin(), v.end(), i) - v.begin()));
}
cout << ans << '\n';
return 0;
}
Copy