#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
pair<int, int> a[N];
int s[N], ss[N];
int main() {
  int n, m;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &ss[i], &a[i].first);
    a[i].second = i;
  }
  s[n - 1] = ss[n - 1];
  for (int i = n - 2; i >= 0; i--) s[i] = ss[i] + s[i + 1];
  sort(a, a + n);
  int now = n, ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i].second < now) {
      ans += (a[i].first * (s[a[i].second] - s[now]));
      now = a[i].second;
    }
  }
  printf("%d\n", ans);
  return 0;
}
