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