#include <bits/stdc++.h>
using std::cin;
using std::cos;
using std::cout;
using std::endl;
using std::make_pair;
using std::max;
using std::min;
using std::next_permutation;
using std::pair;
using std::priority_queue;
using std::queue;
using std::random_shuffle;
using std::set;
using std::sin;
using std::sort;
using std::sqrt;
using std::stack;
using std::string;
using std::stringstream;
using std::swap;
using std::vector;
const long double PI = 3.14159265358979323846;
int main() {
  int n;
  cin >> n;
  vector<pair<long long, long long> > figures(n);
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> figures[i].second >> figures[i].first;
    sum += figures[i].second;
  }
  sort(figures.begin(), figures.end());
  int t;
  cin >> t;
  vector<long long> p(t);
  for (int i = 0; i < t; ++i) {
    cin >> p[i];
  }
  p.push_back(sum);
  for (int i = t; i > 0; --i) {
    p[i] -= p[i - 1];
  }
  long long res = 0;
  int j = 0;
  for (int i = 0; i < n; ++i) {
    while (figures[i].second > p[j]) {
      res += figures[i].first * p[j] * (j + 1);
      figures[i].second -= p[j];
      ++j;
    }
    p[j] -= figures[i].second;
    res += figures[i].first * figures[i].second * (j + 1);
  }
  cout << res << endl;
  return 0;
}
