#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int N;
pair<long long, long long> F[MAXN];
int curP;
int T;
long long P[MAXN];
long long taken;
long long answer;
int main() {
  cin >> N;
  for (int i = 0; i < (int)(N); ++i) {
    int k, c;
    cin >> k >> c;
    F[i] = make_pair(c, k);
  }
  sort(F, F + N);
  cin >> T;
  for (int i = 0; i < (int)(T); ++i) cin >> P[i];
  P[T++] = (long long)1e15;
  for (int i = 0; i < (int)(N); ++i) {
    while (F[i].second > 0) {
      while (taken >= P[curP]) curP++;
      long long toTake = min(F[i].second, P[curP] - taken);
      taken += toTake;
      F[i].second -= toTake;
      answer += (curP + 1) * toTake * F[i].first;
    }
  }
  cout << answer << endl;
  return 0;
}
