#include <bits/stdc++.h>
using namespace std;
const int oo = 1 << 20;
const double PI = M_PI;
const double EPS = 1e-15;
const int MaxN = 105;
int n, t;
long long P[MaxN];
pair<long long, long long> M[MaxN];
long long tot, answer;
int main() {
  cin.sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> M[i].second;
    cin >> M[i].first;
    tot = tot + M[i].second;
  }
  sort(M, M + n);
  cin >> t;
  for (int i = 0; i < t; i++) cin >> P[i];
  if (P[t - 1] < tot) P[t++] = tot;
  tot = 0;
  int i = 0;
  int j = 0;
  while (i < n) {
    if (tot + M[i].second >= P[j]) {
      long long delta = P[j] - tot;
      answer = answer + delta * (long long)(j + 1) * M[i].first;
      M[i].second -= delta;
      tot = P[j];
      if (M[i].second == 0) i = i + 1;
      j = j + 1;
    } else {
      answer = answer + M[i].second * (long long)(j + 1) * M[i].first;
      tot = tot + M[i].second;
      i = i + 1;
    }
  }
  cout << answer << endl;
  return 0;
}
