#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  int result;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    result += A[i];
  }
  int Q;
  cin >> Q;
  int b, c;
  Graph G(Q);
  for (int i = 0; i < Q; i++) {
    cin >> b >> c;
    G[b].push_back(c);
  }
  int diff = 0;
  for (int i = 1; i < (int)G.size(); i++) {
    diff = i - G[i][G[i].size() - 1];
  }
  cout << result + diff << endl;
  return 0;
}
