#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  long long int n, i, t, k, c, s = 0, x, sum = 0, st1 = 0, st2 = 0, curr = 0;
  cin >> n;
  vector<pair<long long int, long long int> > v;
  vector<long long int> p;
  for (i = 0; i < n; i++) {
    cin >> k >> c;
    v.push_back(make_pair(c, k));
  }
  cin >> t;
  for (i = 0; i < t; i++) {
    cin >> x;
    s = x;
    p.push_back(s);
  }
  p.push_back(100000000000000);
  sort(v.begin(), v.end());
  while (st1 < n) {
    if (curr + v[st1].second < p[st2]) {
      sum += (st2 + 1) * (v[st1].first) * (v[st1].second);
      curr += v[st1].second;
      st1++;
    } else {
      long long int rem = p[st2] - curr;
      curr += rem;
      sum += (rem) * (st2 + 1) * (v[st1].first);
      v[st1].second -= rem;
      st2++;
      if (!v[st1].second) {
        st1++;
      }
    }
  }
  cout << sum;
}
