#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  vector<pair<long long int, long long int>> v;
  for (long long int i = 0; i < n; i++) {
    long long int x, y;
    cin >> x >> y;
    v.push_back({y, x});
  }
  sort(v.begin(), v.end());
  long long int t;
  cin >> t;
  long long int p[t];
  long long int r[t];
  for (long long int i = 0; i < t; i++) {
    cin >> p[i];
    r[i] = p[i];
  }
  for (long long int i = 1; i < t; i++) {
    p[i] = (r[i] - r[i - 1]);
  }
  long long int ans = 0;
  long long int f = 1;
  for (long long int i = 0; i < t; i++) {
    long long int g = p[i];
    for (long long int j = 0; j < v.size(); j++) {
      if ((v[j].second) >= g) {
        ans += ((v[j].first) * f * g);
        (v[j].second) -= g;
        f++;
        break;
      } else {
        long long int k = g;
        g -= (v[j].second);
        ans += ((k - g) * f * (v[j].first));
        v[j].second = 0;
      }
    }
  }
  for (long long int i = 0; i < v.size(); i++) {
    ans += ((v[i].first) * (v[i].second) * f);
  }
  cout << ans << endl;
  return 0;
}
