#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
int n;
pi a[10005];
int dp[10005];
int main(){
scanf("%d",&n);
for(int i=1; i<=n; i++){
scanf("%d %d",&a[i].first, &a[i].second);
a[i].second = 2 * abs(a[i].second);
}
sort(a+1,a+n+1);
for(int i=1; i<=n; i++){
int maxp = a[i].second;
dp[i] = 1e9;
for(int j=i-1; j>=0; j--){
dp[i] = min(dp[i], dp[j] + max(a[i].first - a[j+1].first, maxp));
maxp = max(a[j].second, maxp);
}
}
printf("%d",dp[n]);
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgojaW5jbHVkZSA8bWF0aC5oPgojaW5jbHVkZSA8bGltaXRzLmg+CiNpbmNsdWRlIDxzdGFjaz4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8ZnVuY3Rpb25hbD4KI2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPG51bWVyaWM+CiNpbmNsdWRlIDxkZXF1ZT4KI2luY2x1ZGUgPHV0aWxpdHk+CiNpbmNsdWRlIDxiaXRzZXQ+CiNpbmNsdWRlIDxpb3N0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKdHlwZWRlZiBsb25nIGxvbmcgbGludDsKdHlwZWRlZiBsb25nIGRvdWJsZSBsbGY7CnR5cGVkZWYgcGFpcjxpbnQsIGludD4gcGk7CiAKaW50IG47CnBpIGFbMTAwMDVdOwppbnQgZHBb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