#include <bits/stdc++.h>
using namespace std;
struct Swimmer {
  int t, c;
  Swimmer(int t, int c) : t(t), c(c) { ; }
};
bool operator<(const Swimmer &s, const Swimmer &t) { return s.t < t.t; }
int main() {
  int n, t, c;
  while (cin >> n, n) {
    vector<Swimmer> vs;
    for (int i = 0; i < n; ++i) {
      cin >> t >> c;
      vs.push_back(Swimmer(t, c));
    }
    sort(vs.begin(), vs.end());
    queue<pair<int, int> > q1, q2;
    for (int i = 0; i < n; ++i) q1.push(make_pair(vs[i].t, i));
    int time, ans = 0;
    for (time = 0; time < 300 * 250 + 1; time++) {
      if (!q1.empty()) {
        if (q1.front().first == time) {
          vector<pair<int, int> > wait;
          while (!q1.empty() && q1.front().first <= time) {
            wait.push_back(
                make_pair(vs[q1.front().second].t, q1.front().second));
            q1.pop();
          }
          if (q1.empty()) {
            while (!q2.empty() &&
                   q2.front().first + vs[q2.front().second].t <= time) {
              vs[q2.front().second].c--;
              if (vs[q2.front().second].c == 0)
                ans = max(ans, q2.front().first);
              else
                wait.push_back(
                    make_pair(vs[q2.front().second].t, q2.front().second));
              q2.pop();
            }
          }
          sort(wait.begin(), wait.end());
          for (int i = 0; i < wait.size(); ++i) {
            q2.push(make_pair(time + wait[i].first, wait[i].second));
          }
        }
      }
      if (!q2.empty()) {
        if (q2.front().first == time) {
          vector<pair<int, int> > wait;
          while (!q2.empty() && q2.front().first <= time) {
            vs[q2.front().second].c--;
            if (vs[q2.front().second].c == 0)
              ans = max(ans, q2.front().first);
            else
              wait.push_back(
                  make_pair(vs[q2.front().second].t, q2.front().second));
            q2.pop();
          }
          if (q2.empty()) {
            while (!q1.empty() &&
                   q1.front().first + vs[q1.front().second].t <= time) {
              wait.push_back(
                  make_pair(vs[q1.front().second].t, q1.front().second));
              q1.pop();
            }
          }
          sort(wait.begin(), wait.end());
          for (int i = 0; i < wait.size(); ++i)
            q1.push(make_pair(time + wait[i].first, wait[i].second));
        }
      }
    }
    cout << ans << endl;
  }
}
