#include <bits/stdc++.h>
using namespace std;
int compare_int(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int serch() {}
int main() {
  int n;
  cin >> n;
  int a[n];
  int b[n];
  int c[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cin >> b[i];
    c[i] = 0;
  }
  qsort(a, n, sizeof(int), compare_int);
  int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    int x = 0;
    for (int j = 0; j < n; j++) {
      if (b[j] == a[i]) {
        for (int k = 0; k < n; k++) {
          if (abs(j - k) > x && c[k] == 0) {
            x = k;
            int y = abs(j - k);
            ans += (y * b[j]);
          }
        }
      }
    }
    c[x] = 1;
  }
  cout << ans << endl;
}
