#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
using namespace std;
const int inf = 1e9;

struct info{
    int t,rt,c;
    info(int t, int rt, int c):t(t),rt(rt),c(c){}
    info(){}
    bool operator<(const info &a) const{
        return t < a.t;
    }
};

int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;

        vector<info> s(n);
        for(int i=0; i<n; i++){
            int t,c;
            cin >> t >> c;
            s[i] = info(t, t, c);
        }
        sort(s.begin(), s.end());

        deque<info> lane[2];
        for(int i=0; i<n; i++){
            lane[0].push_back(s[i]);
        }
        int ans = 0;
        while(!lane[0].empty() || !lane[1].empty()){
            int rt[2] = {(!lane[0].empty())? lane[0].front().rt: inf,
                         (!lane[1].empty())? lane[1].front().rt: inf};
            int rtmin = min(rt[0], rt[1]);
            vector<info> wait[2];
            for(int d=0; d<2; d++){
                if(rt[d] <= rt[1-d]){
                    while(!lane[d].empty() && lane[d].front().rt <= rtmin){
                        info f = lane[d].front();
                        lane[d].pop_front();
                        f.rt = f.t;
                        if(d == 1) f.c--;
                        if(f.c > 0) wait[1-d].push_back(f);
                    }
                }
                for(deque<info>::iterator itr=lane[d].begin(); itr!=lane[d].end(); itr++){
                    itr->rt -= rtmin;
                }
            }
            for(int d=0; d<2; d++){
                sort(wait[d].begin(), wait[d].end());
                for(int i=0; i<(int)wait[d].size(); i++){
                    lane[d].push_back(wait[d][i]);
                }
            }
            ans += rtmin;
        }
        cout << ans << endl;
    }
    return 0;
}

