#include<bits/stdc++.h>
#define all(s) s.begin(), s.end()
#define sz(s) (int) s.size()
using namespace std;
void DeathRoad(){
int n, m; cin >> n >> m;
vector<int> heights(n + 1);
for(int i = 1; i <= n; i++)
cin >> heights[i];
vector<bool> isThereA_Peson(2 * 1000005);
for (int j = 0; j < m; j++){
int a, b; cin >> a >> b;
isThereA_Peson[b] = true;
}
vector<int> freq(2 * 1000005);
for (int i = 1; i <= 2 * 1000005; i++){
freq[i] += freq[i - 1] + isThereA_Peson[i];
}
long long ans = 0;
for (int i = 1; i <= n; i++){
ans += heights[i] - freq[heights[i]];
}
cout << ans;
}
int main() {
ios_base::sync_with_stdio(0);
int T = 1;
//cin >> T;
while (T--)
DeathRoad();
return 0;
}
/***
We're here for death, so let's go to it together!
***/
Copy