#include <bits/stdc++.h>
using namespace std;
struct p {
  int index;
  int num, cost;
};
struct cmp {
  bool operator()(const p &a, const p &b) const {
    if (a.cost == b.cost) return a.index > b.index;
    return a.cost > b.cost;
  }
};
priority_queue<p, vector<p>, cmp> q;
int sum[100001];
int main() {
  int n, ans = 0;
  p pp;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    pp.index = i;
    scanf("%d%d", &pp.num, &pp.cost);
    sum[i] = sum[i - 1] + pp.num;
    q.push(pp);
  }
  while (n) {
    pp = q.top();
    q.pop();
    if (pp.index > n) continue;
    ans += (sum[n] - sum[pp.index - 1]) * pp.cost;
    n = pp.index - 1;
  }
  printf("%d", ans);
  return 0;
}
