#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
void arquivo() {
  freopen("", "r", stdin);
  freopen("", "w", stdout);
}
const int N = 101;
vector<pair<long long, long long> > v;
long long fat[N];
int n, m;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    v.push_back(make_pair(b, a));
  }
  sort(v.begin(), v.end());
  scanf("%d", &m);
  for (int i = 0; i < m; ++i) scanf("%lld", fat + i);
  fat[m] = 0x3F3F3F3F3F3F3F3FLL;
  int j = 0;
  long long ans = 0;
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    long long k = v[i].second;
    long long c = v[i].first;
    while (sum + k >= fat[j]) {
      long long foo = fat[j] - sum;
      ans += foo * (j + 1LL) * c;
      sum = fat[j];
      j++;
      k -= foo;
    }
    ans += k * (j + 1LL) * c;
    sum += k;
  }
  printf("%lld\n", ans);
  return 0;
}
