#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e17;
const long maxn = 105;
pair<long long, long long> a[maxn];
long n, t;
long long limit[maxn];
int main() {
  long q;
  scanf("%ld", &n);
  for (q = 1; q <= n; q++) cin >> a[q].second >> a[q].first;
  sort(a + 1, a + n + 1);
  scanf("%ld", &t);
  for (q = 1; q <= t; q++) cin >> limit[q];
  limit[t + 1] = inf;
  long long done = 0;
  long now = 1;
  long long answer = 0;
  for (long it = 1; it <= n; it++) {
    while (true) {
      if (done + a[it].second > limit[now]) {
        a[it].second -= (limit[now] - done);
        answer += (limit[now] - done) * now * a[it].first;
        done += (limit[now] - done);
        now++;
      } else {
        done += a[it].second;
        answer += a[it].second * now * a[it].first;
        break;
      }
    }
  }
  cout << answer;
}
