#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int inf = (1 << 21);
class state {
 public:
  int t, now, ori;
  int cnt;
  bool operator<(const state& a) const {
    if (now * a.t != a.now * t) return now * a.t < a.now * t;
    return t > a.t;
  }
};
int solve(int n, vector<state>& in) {
  int ans = 0;
  sort((in).begin(), (in).end());
  int m = n;
  while (m) {
    int mint = inf;
    for (int i = 0; i < n; i++) {
      if (in[i].now == inf) continue;
      mint = min(mint, in[i].t - in[i].now % in[i].t);
    }
    for (int i = 0; i < n; i++) {
      if (in[i].now == inf) continue;
      in[i].now += 1;
      int tnow = in[i].now - 1, tt = in[i].t;
      for (int j = 0; j < n; j++) {
        if (in[j].now == inf) continue;
        if (i == j) continue;
        if ((tnow)*in[j].t >= (in[j].now) * tt) continue;
        if (in[i].t <= in[j].t) continue;
        if (in[j].now - in[i].now < 0) continue;
        double t = (in[i].t * in[j].t) * (in[j].now - in[i].now) /
                   (double)(in[j].t - in[i].t);
        if (t < 0) continue;
        if (t < mint) {
          mint = (int)(t + 1);
        }
      }
      in[i].now -= 1;
    }
    for (int i = 0; i < n; i++) {
      if (in[i].now == inf) continue;
      in[i].now += mint;
      int tnow = in[i].now - mint, tt = in[i].t;
      for (int j = 0; j < n; j++) {
        if (in[j].now == inf) continue;
        if (i == j) continue;
        if ((tnow)*in[j].t >= (in[j].now) * tt) continue;
        if ((in[i].now) * in[j].t >= (in[j].now + mint) * in[i].t) {
          in[i].now = in[j].now + mint;
          in[i].t = in[j].t;
        }
      }
      in[i].now -= mint;
    }
    for (int i = 0; i < n; i++) {
      if (in[i].now == inf) continue;
      in[i].now += mint;
    }
    for (int i = 0; i < n; i++) {
      if (in[i].now == inf) continue;
      if (in[i].now % in[i].t == 0) {
        if (in[i].now / in[i].t == 1) {
          in[i].t = in[i].ori;
          in[i].now = in[i].ori;
        } else if (in[i].now / in[i].t == 2) {
          in[i].t = in[i].ori;
          in[i].now = 0;
          in[i].cnt--;
          if (in[i].cnt == 0) in[i].now = inf, m--;
        }
      }
    }
    ans += mint;
  }
  return ans;
}
int main() {
  int n;
  while (cin >> n && n) {
    vector<state> in;
    for (int i = 0; i < n; i++) {
      int t;
      int lap;
      cin >> t >> lap;
      in.push_back((state){t, 0, t, lap});
    }
    cout << solve(n, in) << endl;
  }
}
