#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, i, meat = 0, cost = 0;
  cin >> n;
  long long a[n], p[n];
  for (long long i = 0; i < n; i++) cin >> a[i] >> p[i];
  for (long long i = 0; i < n; i++) {
    if (meat >= a[i]) {
      meat -= a[i];
    } else {
      cost += a[i] * p[i];
      long long j = i + 1;
      while (p[j] > p[i] && j < n) {
        meat += a[j];
        cost += a[j] * p[i];
        j++;
      }
    }
  }
  cout << cost;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t, i;
  t = 1;
  for (i = 0; i < t; i++) {
    solve();
  }
  return 0;
}
