#include <bits/stdc++.h>
using namespace std;
int main(int argc, char *argv[]) {
  int n;
  scanf("%d", &n);
  vector<pair<int, long> > g;
  for (int a, i = 0; i < n; i++) {
    long q;
    scanf("%ld %d", &q, &a);
    g.push_back(make_pair(a, q));
  }
  int m;
  scanf("%d", &m);
  vector<long long> p(m + 1, 1);
  p[m] = 1LL * 1000 * 1000 * 1000 * 1000 * 1000;
  for (int i = 0; i < m; i++) scanf("%I64d", &p[i]);
  sort(g.begin(), g.end());
  long long ans = 0;
  long long cur = 0;
  int q = 1;
  int j = 0;
  for (int i = 0; i < m + 1; i++) {
    p[i] -= cur;
    for (; p[i] && j < n; j++) {
      if (g[j].second <= p[i]) {
        ans += 1LL * g[j].second * q * g[j].first;
        cur += g[j].second;
        p[i] -= g[j].second;
        g[j].second = 0;
      }
      if (g[j].second > p[i]) {
        ans += 1LL * p[i] * q * g[j].first;
        cur += 1LL * p[i];
        g[j].second -= p[i];
        p[i] = 0;
        break;
      }
    }
    q++;
  }
  printf("%I64d\n", ans);
  return EXIT_SUCCESS;
}
