#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-11;
const int p = 1000000007;
int countbit(int n) { return n == 0 ? 0 : countbit(n / 2) + n % 2; }
int lowbit(int n) { return (n ^ (n - 1)) & n; }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
long long toInt64(string s) {
  istringstream sin(s);
  long long t;
  sin >> t;
  return t;
}
template <typename T>
T sqr(T n) {
  return n * n;
}
template <typename T>
void out(T& v) {
  for (int i = 0; i < v.size(); i++) cout << v[i] << ' ';
  cout << endl;
}
int main() {
  double start = static_cast<double>(clock());
  int n;
  cin >> n;
  vector<pair<long long, long long> > figure(n);
  for (int i = 0; i < n; i++) {
    long long count, price;
    cin >> count >> price;
    figure[i] = (make_pair((price), (count)));
  }
  int t;
  cin >> t;
  vector<long long> p(t + 1);
  for (int i = 0; i < t; i++) cin >> p[i];
  for (int i = t - 1; i > 0; i--) p[i] -= p[i - 1];
  p[t] = 1000000000000000ll;
  sort(figure.begin(), figure.end());
  long long result = 0;
  int f = 1;
  int curP = 0;
  for (int i = 0; i < figure.size(); i++) {
    while (p[curP] > 0) {
      if (p[curP] > figure[i].second) {
        p[curP] -= figure[i].second;
        result += figure[i].first * figure[i].second * f;
        figure[i].second = 0;
        break;
      } else {
        result += figure[i].first * p[curP] * f;
        figure[i].second -= p[curP];
        p[curP] = 0;
        curP++;
        f++;
      }
    }
  }
  cout << result << endl;
  return 0;
}
