#include <bits/stdc++.h>
using namespace std;
void pairsort(int n, int *a, int *b) {
  pair<int, int> c[50];
  for (int i = 0; i < (n); i++) c[i] = make_pair(-a[i], b[i]);
  sort(c, c + n);
  for (int i = 0; i < (n); i++) a[i] = -c[i].first, b[i] = c[i].second;
}
int main() {
  for (int n; scanf("%d", &n), n;) {
    int pace[50], lap[50];
    for (int i = 0; i < (n); i++) scanf("%d%d", pace + i, lap + i);
    pairsort(n, pace, lap);
    vector<int> stop[50];
    for (int i = 0; i < (n); i++) {
      int t = 0;
      stop[i].push_back(t);
      for (int j = 0; j < (2 * lap[i]); j++) {
        int t_next = t + pace[i];
        for (int k = 0; k < (i); k++) {
          int idx = lower_bound(stop[k].begin(), stop[k].end(), t) -
                    stop[k].begin() - 1;
          if (idx >= 0 && idx % 2 == j % 2) {
            t_next = max(t_next, stop[k][idx + 1]);
          }
        }
        t = t_next;
        stop[i].push_back(t);
      }
    }
    int ans = 0;
    for (int i = 0; i < (n); i++) ans = max(ans, stop[i].back());
    printf("%d\n", ans);
  }
  return 0;
}
