#include <bits/stdc++.h>
using namespace std;
struct figure {
  long long int number;
  int price;
};
bool bg(figure one, figure two) { return (one.price < two.price); }
int main() {
  int n;
  cin >> n;
  vector<figure> figs(n);
  for (int i = 0; i < n; ++i) {
    cin >> figs[i].number >> figs[i].price;
  }
  int t;
  cin >> t;
  vector<long long int> times(t);
  for (int i = 0; i < t; ++i) {
    cin >> times[i];
  }
  times.push_back(10000000000000);
  sort(figs.begin(), figs.end(), bg);
  long long int summ = 0;
  int FigureLink = 0;
  long long int pieces = 0;
  int mn = 0;
  while (FigureLink < n) {
    if (figs[FigureLink].number == 0) {
      ++FigureLink;
    } else {
      if (pieces >= times[mn]) {
        ++mn;
      }
      long long int localpieces =
          min(times[mn] - pieces, figs[FigureLink].number);
      summ += localpieces * figs[FigureLink].price * (mn + 1);
      pieces += localpieces;
      figs[FigureLink].number -= localpieces;
    }
  }
  cout << summ;
  return 0;
}
