#include <bits/stdc++.h>
using namespace std;
const double EPS = 1E-9;
const int INF = 1 << 30;
struct swimmer {
  int t;
  double pos;
  int lane;
  int rest_loop;
};
int n;
swimmer ss[100];
bool operator<(swimmer s1, swimmer s2) {
  if (s1.rest_loop == 0 || s2.rest_loop == 0)
    return s1.rest_loop > s2.rest_loop;
  else if (s1.lane != s2.lane)
    return s1.lane > s2.lane;
  else {
    if (s1.pos < EPS && s2.pos < EPS)
      return s1.t < s2.t;
    else
      return s1.pos > s2.pos;
  }
}
bool finish() {
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (ss[i].rest_loop > 0) cnt++;
  }
  n = cnt;
  return cnt == 0;
}
void move() {
  for (int i = 0; i < n; i++) {
    ss[i].pos += 1.0 / ss[i].t;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (ss[i].lane == ss[j].lane && ss[i].pos > ss[j].pos) {
        ss[i].pos = ss[j].pos;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (abs(1.0 - ss[i].pos) < EPS) {
      ss[i].pos = 0;
      if (ss[i].lane) {
        ss[i].lane = 0;
        ss[i].rest_loop--;
      } else {
        ss[i].lane = 1;
      }
    }
  }
}
int main() {
  while (cin >> n && n) {
    for (int i = 0; i < n; i++) {
      cin >> ss[i].t >> ss[i].rest_loop;
      ss[i].pos = 0.0;
      ss[i].lane = 0;
    }
    sort(ss, ss + n);
    int cnt = 0;
    while (true) {
      if (finish()) {
        cout << cnt << endl;
        break;
      }
      cnt++;
      move();
      sort(ss, ss + n);
    }
  }
  return 0;
}
