#include <bits/stdc++.h>
using namespace std;
int INF = 1000000000;
struct swimer {
  int goal, rane, res;
};
int n;
int t[60], c[60];
int start[2], goal[2];
swimer sws[60];
int main() {
  while (1) {
    cin >> n;
    if (n == 0) break;
    for (int i = 0; i < n; i++) {
      cin >> t[i] >> c[i];
    }
    for (int i = 0; i < 2; i++) {
      start[i] = 0;
      goal[i] = 0;
    }
    priority_queue<pair<int, int>, vector<pair<int, int>>,
                   greater<pair<int, int>>>
        que;
    for (int i = 0; i < n; i++) {
      pair<int, int> p;
      p.first = 0;
      p.second = i;
      sws[i].goal = t[i];
      sws[i].rane = 0;
      sws[i].res = c[i];
      que.push(p);
    }
    while (!que.empty()) {
      pair<int, int> p = que.top();
      que.pop();
      swimer s = sws[p.second];
      if (p.first > start[s.rane]) {
        if (goal[s.rane] > s.goal) {
          sws[p.second].goal = goal[s.rane];
        } else {
          start[s.rane] = p.first;
          goal[s.rane] = s.goal;
        }
      } else {
        goal[s.rane] = max(s.goal, goal[s.rane]);
      }
      if (s.rane == 1) {
        sws[p.second].res--;
      }
      if (sws[p.second].res > 0) {
        pair<int, int> next_p = pair<int, int>(goal[s.rane], p.second);
        sws[p.second].rane = (s.rane + 1) % 2;
        sws[p.second].goal = next_p.first + t[p.second];
        que.push(next_p);
      }
    }
    cout << goal[1] << endl;
  }
}
