#include <bits/stdc++.h>
using namespace std;
const long long N = 200;
long long n, m, ans, now, sum;
long long p[N];
struct number {
  long long w, c;
} num[N];
inline bool cmp(number a, number b) { return a.c < b.c; }
signed main() {
  scanf("%lld", &n);
  for (register long long i = 1; i <= n; ++i)
    scanf("%lld%lld", &num[i].w, &num[i].c);
  sort(num + 1, num + n + 1, cmp);
  scanf("%lld", &m);
  for (register long long i = 1; i <= m; ++i) scanf("%lld", &p[i]);
  ans = 0;
  now = 1;
  m++;
  p[m] = 1e18;
  for (register long long i = 1; i <= m; ++i) {
    sum = p[i - 1];
    while (sum + num[now].w <= p[i] && now <= n)
      ans += num[now].w * num[now].c * i, sum += num[now].w, now++;
    if (now == n + 1) break;
    if (sum < p[i])
      ans += (p[i] - sum) * num[now].c * i, num[now].w -= (p[i] - sum);
  }
  printf("%lld\n", ans);
  return 0;
}
