#include <bits/stdc++.h>
using namespace std;
struct Post {
  unsigned long long k;
  unsigned long long c;
};
bool cmp(Post a, Post b) { return a.c < b.c; }
unsigned long long p[110];
unsigned long long num, a = 1, ans, m;
Post t[110];
int main(void) {
  unsigned long long n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t[i].k >> t[i].c;
  }
  sort(t + 1, t + 1 + n, cmp);
  cin >> m;
  for (int i = 1; i <= m; i++) {
    cin >> p[i];
  }
  for (int i = m; i >= 1; i--) {
    p[i] -= p[i - 1];
  }
  p[m + 1] = 0x7fffffffffff;
  for (int i = 1; i <= n; i++) {
    while (t[i].k > p[a]) {
      ans += 1ll * p[a] * t[i].c * a;
      t[i].k -= p[a];
      a++;
    }
    ans += 1ll * t[i].k * t[i].c * a;
    p[a] -= t[i].k;
  }
  cout << ans << endl;
  return 0;
}
