#include <bits/stdc++.h>
using namespace std;
struct P {
  pair<int, int> time;
  bool dir;
  P(pair<int, int> time = pair<int, int>((1 << 29), (1 << 29)),
    bool dir = false)
      : time(time), dir(dir) {}
};
int ans;
int n;
void compute(vector<vector<P> > &record, pair<int, int> person) {
  int cur = 0;
  record.push_back(vector<P>());
  for (int i = 0; i < person.second * 2; i++) {
    bool dir = i % 2;
    int next = cur + person.first;
    for (int j = 0; j < record.size() - 1; j++) {
      for (int k = 0; k < record[j].size(); k++) {
        P p = record[j][k];
        if (p.dir != dir) continue;
        if (p.time.first > cur) break;
        if (p.time.second == next || p.time.first == cur) {
          break;
        } else if (p.time.first < next && next < p.time.second) {
          next = p.time.second;
          goto Skip;
        }
      }
    }
  Skip:;
    record[record.size() - 1].push_back(P(pair<int, int>(cur, next), dir));
    cur = next;
    ans = max(ans, next);
  }
}
int main() {
  while (scanf("%d", &n), n) {
    ans = 0;
    vector<pair<int, int> > info(n);
    for (int i = 0; i < n; i++) scanf("%d %d", &info[i].first, &info[i].second);
    sort((info).begin(), (info).end(), greater<pair<int, int> >());
    vector<vector<P> > record;
    for (int i = 0; i < n; i++) compute(record, info[i]);
    printf("%d\n", ans);
  }
  return 0;
}
