#include <bits/stdc++.h>
using namespace std;
typedef struct {
  long long num, cost;
} figures;
bool cmp(figures a, figures b) { return a.cost < b.cost; }
int main() {
  int i, j, k, l, n, m;
  cin >> n;
  figures fig[n];
  for (int i = 0; i < (n); i++) cin >> fig[i].num >> fig[i].cost;
  long long t;
  cin >> t;
  long long dest[t];
  for (int i = 0; i < (t); i++) cin >> dest[i];
  sort(fig, fig + n, cmp);
  sort(dest, dest + t);
  long long prev1 = 0, prev2 = 0;
  for (int i = (0); i < (t); i++) {
    prev2 = dest[i];
    dest[i] -= prev1;
    prev1 = prev2;
  }
  int ind = 0;
  long long f = 1, ct = 0;
  long long tot = 0;
  while (ind < n) {
    long long can;
    long long avail = fig[ind].num;
    if (ct < t)
      can = min(avail, dest[ct]);
    else
      can = avail;
    tot += can * f * fig[ind].cost;
    if (ct < t) {
      dest[ct] -= can;
      if (dest[ct] == 0) {
        f = min(f + 1, t + 1);
        ct++;
      }
    }
    fig[ind].num -= can;
    if (fig[ind].num == 0) {
      ind++;
    }
  }
  cout << tot << endl;
  return 0;
}
