#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323846
#define mod 1000000007
#define ll long long
#define vi vector<int>
#define ii pair<int, int>
#define pb push_back
#define all(c) (c).begin(), (c).end()
const int N = 2e5;
int n, m, h[N], a[N], b[N], cs[N + 1];
ll ans;
bool occ[N + 1];
int main() {
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
cin >> n >> m;
for (int i = 0; i < n; ++i)
cin >> h[i];
for (int i = 0; i < m; ++i) {
cin >> a[i] >> b[i];
occ[b[i]] = 1;
}
sort(h, h + n);
cs[0] = n;
for (int j = 0, i = 1; i < N + 1; ++i) {
cs[i] = cs[i - 1];
while (h[j] < i) {
++j;
--cs[i];
}
}
for (int i = 1; i <= h[n - 1]; ++i) {
if (!occ[i]) {
ans += cs[i];
}
}
cout << ans << endl;
}
Copy