#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i, j, k;
  cin >> n;
  vector<pair<long long, long long>> pris(n);
  for (i = 0; i < n; i++) {
    cin >> j >> k;
    pris[i] = make_pair(k, j);
  }
  cin >> j;
  vector<long long> p(j + 1);
  for (i = 0; i < j; i++) cin >> p[i];
  p[j] = 1111111111111;
  sort(pris.begin(), pris.end());
  long long f = 1, ans = p[0], cnt = 0, res = 0;
  i = 0;
  while (i < n) {
    if (cnt + pris[i].second <= ans) {
      cnt += pris[i].second;
      res += f * pris[i].first * pris[i].second;
      i++;
    } else {
      res += f * pris[i].first * (ans - cnt);
      pris[i].second = pris[i].second + cnt - ans;
      cnt = ans;
      f += 1;
      ans = p[f - 1];
    }
  }
  cout << res << endl;
}
