#include <bits/stdc++.h>
using namespace std;
const long long MX = 100000;
const long long MOD = 1000000007;
const int base = 131;
const int inf = 222222222;
long long fast_exp(long long base, long long exp, long long mod) {
  long long res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % mod;
    base = (base * base) % mod;
    exp /= 2;
  }
  return res;
}
long long inv(long long a, long long m) { return fast_exp(a, m - 2, m); }
pair<long long, long long> a[111];
long long p[111];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i].second >> a[i].first;
  int t;
  cin >> t;
  for (int i = 1; i <= t; i++) cin >> p[i];
  p[t + 1] = (1LL << 60);
  sort(a + 1, a + n + 1);
  long long i, j, diff, use = 0;
  long long sum = 0;
  for (i = 1, j = 1; i <= n; i++) {
    while (a[i].second) {
      diff = min(a[i].second, p[j] - use);
      sum += j * diff * a[i].first;
      a[i].second -= diff;
      if ((use += diff) == p[j]) ++j;
    }
  }
  cout << sum;
  return 0;
}
