#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> mas[110];
long long mn[110], n, t;
long long ans = 0;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> mas[i].second >> mas[i].first;
  sort(mas + 1, mas + n + 1);
  cin >> t;
  for (int i = 1; i <= t; i++) cin >> mn[i];
  mn[t + 1] = (long long)1000000000 * 1000;
  long long st1 = 1, st2 = 1;
  long long ost = mn[1];
  while (st1 <= n) {
    if (mas[st1].second <= ost) {
      ans = ans + mas[st1].second * mas[st1].first * st2;
      ost -= mas[st1].second;
      mas[st1].second = 0;
      st1++;
      continue;
    } else {
      ans = ans + st2 * ost * mas[st1].first;
      mas[st1].second -= ost;
      st2++;
      ost = mn[st2] - mn[st2 - 1];
    }
  }
  cout << ans;
}
