#include <bits/stdc++.h>
struct figure_t {
  long long num;
  long long cost;
};
int figure_num;
figure_t figures[100];
int kizyun_num;
long long kizyun[100];
int qsort_comp(const void* x, const void* y) {
  const figure_t* a = (const figure_t*)x;
  const figure_t* b = (const figure_t*)y;
  if ((a->cost) > (b->cost)) return 1;
  if ((a->cost) < (b->cost)) return -1;
  return 0;
}
int main(void) {
  int i;
  scanf("%d", &figure_num);
  for (i = 0; i < figure_num; i++) {
    scanf("%I64d%I64d", &figures[i].num, &figures[i].cost);
  }
  qsort(figures, figure_num, sizeof(figure_t), qsort_comp);
  scanf("%d", &kizyun_num);
  for (i = 0; i < kizyun_num; i++) {
    scanf("%I64d", &kizyun[i]);
  }
  for (i = kizyun_num - 1; i > 0; i--) {
    kizyun[i] -= kizyun[i - 1];
  }
  int now_figure = 0;
  int now_kizyun = 0;
  long long score = 0;
  while (now_figure < figure_num) {
    if (now_kizyun >= kizyun_num) {
      score +=
          figures[now_figure].cost * figures[now_figure].num * (now_kizyun + 1);
      now_figure++;
    } else {
      if (figures[now_figure].num > kizyun[now_kizyun]) {
        score +=
            figures[now_figure].cost * kizyun[now_kizyun] * (now_kizyun + 1);
        figures[now_figure].num -= kizyun[now_kizyun];
        now_kizyun++;
      } else {
        score += figures[now_figure].cost * figures[now_figure].num *
                 (now_kizyun + 1);
        kizyun[now_kizyun] -= figures[now_figure].num;
        now_figure++;
      }
    }
  }
  printf("%I64d\n", score);
  return 0;
}
