#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  long long k, c, t, fact = 1;
  long long temp, score = 0;
  vector<long long> p;
  multimap<long long, long long> list;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> k >> c;
    list.insert(std::pair<long long, long long>(c, k));
  }
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> temp;
    p.push_back(temp);
  }
  multimap<long long, long long>::iterator it = list.begin();
  long long terms = 0;
  for (int i = 0; i < p.size(); i++) {
    while (terms < p[i]) {
      if (it == list.end()) break;
      if ((*it).second >= (p[i] - terms)) {
        score += (*it).first * (p[i] - terms) * fact;
        (*it).second -= (int)(p[i] - terms);
        terms += (p[i] - terms);
        ++fact;
      } else {
        score += (*it).first * (*it).second * fact;
        terms += (long long)(*it).second;
        ++it;
      }
    }
  }
  for (multimap<long long, long long>::iterator x = it; x != list.end(); ++x) {
    score += (*x).first * (*x).second * fact;
  }
  cout << score << endl;
  return 0;
}
