#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
#define N 200010
struct arr{
int s;
long long t;
}cow[N];
int n;
long long ans[N] = {0};
inline int getint(){
char ch;
int x = 0;
while (!isdigit(ch = getchar()));
x = ch - 48;
while (isdigit(ch = getchar())) x = x * 10 + ch - 48;
return x;
}
int main(){
freopen("boarding.in","r",stdin);
freopen("boarding.out","w",stdout);
n = getint();
for (int i = 1; i <= n; i++){
cow[i].s = getint();
cow[i].t = getint();
}
for (int i = 1; i <= n; i++){
ans[i] += cow[i].s + n - i;
ans[i] += cow[i].t;
}
long long anss = 0;
for (int i = 1; i <= n; i++){
for (int j = n; j > i; j--){
if (cow[i].s > cow[j].s) ans[i] += cow[j].t;
}
cout << ans[i] << endl;
anss = max(ans[i],anss);
}
printf("%I64d\n",anss);
return 0;
}