#include using namespace std; // #define int long long #define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i) #define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i) #define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--) #define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--) #define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i) #define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i) #define SORT(v, n) sort(v, v + n); #define REVERSE(v, n) reverse(v, v+n); #define vsort(v) sort(v.begin(), v.end()); #define all(v) v.begin(), v.end() #define mp(n, m) make_pair(n, m); #define cout(d) cout<; using vvi = vector; using vll = vector; using vvll = vector; using pii = pair; using pll = pair; using vs = vector; using vpll = vector>; using vtp = vector>; using vb = vector; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const ll INF = 1e9; const ll MOD = 1e9+7; const ll LINF = 1e18; ll dp[1001001][20]; // 集合sは既に並んでいて、最後がiであるときのしおり間距離の最大 ll bitcount(ll x){ if(x==0) return 0; return bitcount(x>>1)+(x&1); } string to_binary(ll n, int digit = 0) { string res = ""; while (n) { if (n & 1) res = "1" + res; else res = "0" + res; n >>= 1; } if (0 < digit) { int n = digit - res.length(); rep(i, n) res = "0" + res; } return res; } signed main() { cin.tie( 0 ); ios::sync_with_stdio( false ); ll n; cin>>n; vpll p(n); rep(i,n){ ll a,b; cin>>a>>b; p[i]={a,b}; } rep(s,1<>i&1)==0) continue; if((s>>j&1)) continue; ll d=(p[i].second-p[i].first)+p[j].first; chmin(dp[s|(1<