#include <bits/stdc++.h>
using namespace std;
int tx[] = {0, 1, 0, -1};
int ty[] = {-1, 0, 1, 0};
static const double EPS = 1e-8;
long long GCD(long long a, long long b) { return b > 0 ? GCD(b, a % b) : a; }
long long LCM(long long a, long long b) { return a / GCD(a, b) * b; }
class Swimmer {
 public:
  int current_pace;
  int natural_pace;
  int laps;
  double pos;
  double prev_pos;
  int dir;
  Swimmer(int current_pace, int natural_pace, int laps)
      : current_pace(current_pace),
        natural_pace(natural_pace),
        laps(laps),
        pos(0),
        prev_pos(0),
        dir(0) {}
};
int main() {
  int num_of_swimmers;
  while (~scanf("%d", &num_of_swimmers)) {
    if (num_of_swimmers == 0) break;
    vector<Swimmer> swimmers;
    for (int i = 0; i < num_of_swimmers; i++) {
      int natural_pace;
      int laps;
      scanf("%d %d", &natural_pace, &laps);
      swimmers.push_back(Swimmer(natural_pace, natural_pace, laps));
    }
    int res = 0;
    for (int time = 0; time <= 150000; time++) {
      bool has_swimmer = false;
      for (int i = 0; i < swimmers.size(); i++) {
        if (swimmers[i].laps == 0) continue;
        has_swimmer = true;
        double speed = 1.0 / (double)swimmers[i].current_pace;
        swimmers[i].prev_pos = swimmers[i].pos;
        swimmers[i].pos += speed * 1.0;
      }
      if (!has_swimmer) {
        res = time;
        break;
      }
      for (int i = 0; i < swimmers.size(); i++) {
        if (swimmers[i].pos >= 1.0 - EPS) continue;
        if (swimmers[i].laps == 0) continue;
        for (int j = i + 1; j < swimmers.size(); j++) {
          if (swimmers[j].pos >= 1.0 - EPS) continue;
          if (swimmers[j].laps == 0) continue;
          if (swimmers[i].dir == swimmers[j].dir &&
              abs(swimmers[i].pos) > EPS) {
            if (swimmers[i].pos > swimmers[j].pos &&
                swimmers[i].prev_pos < swimmers[j].prev_pos) {
              swimmers[i].pos = swimmers[j].pos;
              swimmers[i].current_pace = swimmers[j].current_pace;
            } else if (swimmers[i].pos < swimmers[j].pos &&
                       swimmers[i].prev_pos > swimmers[j].prev_pos) {
              swimmers[j].pos = swimmers[i].pos;
              swimmers[j].current_pace = swimmers[i].current_pace;
            } else if (abs(swimmers[i].pos - swimmers[j].pos) < EPS) {
              swimmers[i].current_pace =
                  max(swimmers[i].current_pace, swimmers[j].current_pace);
              swimmers[j].current_pace =
                  max(swimmers[i].current_pace, swimmers[j].current_pace);
            }
          }
        }
      }
      for (int i = 0; i < swimmers.size(); i++) {
        if (swimmers[i].pos >= 1.0 - EPS) {
          if (swimmers[i].dir == 1) {
            swimmers[i].laps--;
          }
          swimmers[i].dir = (swimmers[i].dir == 1 ? 0 : 1);
          swimmers[i].current_pace = swimmers[i].natural_pace;
          swimmers[i].pos = 0.0;
        }
      }
    }
    printf("%d\n", res);
  }
}
