#include <bits/stdc++.h>
using namespace std;

const int MAXN = 55;
const int INF = 1<<28;

struct S {
  int t, c, in;
  bool operator < (const S &s) const {
    return t < s.t;
  }
  bool reached(int now) {
    return now - in >= t;
  }
};

int n;
S s[MAXN];

int main() {
  while (cin >> n && n) {
    for (int i = 0; i < n; ++i) {
      cin >> s[i].t >> s[i].c;
      s[i].in = 0;
    }
    sort(s, s + n);
    deque<S> que[2];
    for (int i = 0; i < n; ++i) que[0].push_back(s[i]);
    int t, finished;
    for (t = 1, finished = 0; finished < n; ++t) {
      for (int k = 0; k < 2; ++k) {
        vector<S> v;
        while (que[k].size() && que[k].front().reached(t)) {
          S s = que[k].front();
          que[k].pop_front();
          v.push_back(s);

        }
        sort(v.begin(), v.end());
        for (int i = 0; i < v.size(); ++i) {
          S &s = v[i];
          s.in = t;
          if (k == 1 && --s.c == 0) {
            finished += 1;
            continue;
          }
          que[1-k].push_back(v[i]);
        }
      }
    }
    cout << t - 1 << endl;
  }
  return 0;
}