#include <bits/stdc++.h>
using namespace std;
pair<int, int> v[1010];
int n, t, cf;
long long sol, futute, p[1010];
int main() {
  cin >> n;
  for (long long i = 1; i <= n; ++i) cin >> v[i].second >> v[i].first;
  sort(v + 1, v + n + 1);
  cin >> t;
  for (long long i = 1; i <= t; ++i) cin >> p[i];
  p[t + 1] = 1LL << 60;
  cf = 1;
  for (long long i = 1; i <= n; ++i) {
    while (v[i].second) {
      if (v[i].second <= p[cf] - futute) {
        futute += v[i].second;
        sol += 1LL * v[i].second * cf * v[i].first;
        v[i].second = 0;
      } else if (v[i].second > p[cf] - futute) {
        sol += 1LL * (p[cf] - futute) * cf * v[i].first;
        v[i].second -= p[cf] - futute;
        futute = p[cf];
        ++cf;
      }
    }
  }
  cout << sol;
  return 0;
}
