#include <bits/stdc++.h>
using namespace std;
struct Swimmer {
  int t, c, e;
  Swimmer(int t, int c, int e) : t(t), c(c), e(e) {}
};
const int INF = 1000000000;
int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    vector<pair<int, int> > input(n);
    for (int i = 0; i < n; ++i) {
      cin >> input[i].first >> input[i].second;
    }
    queue<Swimmer> forward, backward;
    sort(input.begin(), input.end());
    for (int i = 0; i < n; ++i) {
      int t = input[i].first, c = input[i].second;
      forward.push(Swimmer(t, c, t));
    }
    int answer = 0;
    while (!forward.empty() || !backward.empty()) {
      int ft = (forward.empty() ? INF : forward.front().e);
      int bt = (backward.empty() ? INF : backward.front().e);
      int tm = min(ft, bt);
      answer = tm;
      queue<Swimmer> &q = (ft < bt) ? forward : backward;
      vector<pair<int, int> > next;
      while (!q.empty() && q.front().e <= tm) {
        Swimmer sw = q.front();
        q.pop();
        if (ft >= bt && --sw.c == 0) {
          continue;
        }
        next.push_back(pair<int, int>(sw.t, sw.c));
      }
      sort(next.begin(), next.end());
      queue<Swimmer> &opp = (ft < bt) ? backward : forward;
      for (int i = 0; i < next.size(); ++i) {
        int t = next[i].first, c = next[i].second;
        opp.push(Swimmer(t, c, t + tm));
      }
    }
    cout << answer << endl;
  }
  return 0;
}
