#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  pair<long long, long long> arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i].second >> arr[i].first;
  int t;
  sort(arr, arr + n);
  cin >> t;
  long long ar[t];
  for (int i = 0; i < t; i++) cin >> ar[i];
  int i = 0, f = 1;
  sort(ar, ar + t);
  long long ans = 0, r = 0;
  for (int j = 0; j < n; j++) {
    while (arr[j].second) {
      if (i == t) {
        ans += arr[j].second * f * arr[j].first;
        break;
      }
      if (r == ar[i]) {
        i++;
        f++;
      }
      long long a = ar[i] - r;
      if (arr[j].second - a >= 0) {
        ans += (a * f * arr[j].first);
        r = ar[i];
        arr[j].second -= a;
      } else {
        ans += arr[j].second * f * arr[j].first;
        r += arr[j].second;
        arr[j].second = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
