#include <cstdio>
#define NN 201000
using namespace std;
int a[NN],b[NN],c[NN];
int n,ans;
int main(){
freopen("boarding.in","r",stdin);
freopen("boarding.out","w",stdout);
int i,tem;
scanf("%d",&n);
for (i = 1; i <= n; i++){
scanf("%d%d",&a[i],&b[i]);
c[i] = 1;
if (a[i] == n) tem = i;
}
a[0] = n+1;
c[0] = 0;
ans += 2*n-tem;
for (i = n-1; i >= 0; i--){
if (a[i] > a[i+1])
ans += b[i+1];
else{
if (b[i+1]-b[i] > (a[i+1]-a[i])*c[i]) ans += b[i+1]-b[i]-(a[i+1]-a[i])*c[i];
}
}
printf("%d",ans);
return 0;
}