#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  vector<int> B(n);
  vector<int> C(n - 1);
  for (int i = 0; i < n - 1; ++i) {
    cin >> C[i];
  }
  int add = 0;
  int res = 0;
  for (int i = 0; i < n; ++i) {
    cin >> A[i] >> B[i];
    if (A[i] + 1 == A[i + 1]) add += C[i + 1];
    res += B[i];
  }
  cout << res + add << endl;
}
