#include <bits/stdc++.h>
const int N = 100010;
const unsigned long long inf = 1e19;
using namespace std;
pair<int, int> a[N];
unsigned long long p[N];
int main() {
  int n, t;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i].second >> a[i].first;
  cin >> t;
  sort(a, a + n);
  for (int i = 0; i < t; i++) cin >> p[i];
  p[t] = inf;
  unsigned long long ret = 0, l = 0;
  for (int i = 0, j = 0; i < n;) {
    if (p[j] - l < a[i].second) {
      ret += (p[j] - l) * (j + 1) * a[i].first;
      a[i].second -= p[j] - l;
      l += p[j] - l;
      j++;
    } else {
      ret += 1ll * a[i].second * (j + 1) * a[i].first;
      l += a[i].second;
      i++;
    }
  }
  cout << ret << endl;
  return 0;
}
