#include #define _TP template #define _CT const #define _CC constexpr #define _US using _US namespace std; namespace vies = std::views; _US std::cin; _US std::cout; _US sstream = stringstream; #define fi first #define se second #define endl '\n' #define sn(i, c) " \n"[i == c]; #define pf(a) push_front(a) #define pb(a) push_back(a) #define eb(a) emplace_back(a) #define ppf() pop_front() #define ppb() pop_back() #define pp() pop() #define ins(a) insert(a) #define emp(a) emplace(a) #define mp(f, s) make_pair(f, s) #define A(a) begin(a), end(a) #define I(a, i) begin(a), begin(a) + i _TP _US vc = vector; _TP _US vv = vc>; _TP _US v3 = vv>; _TP _US v4 = vv>; _TP _US gr = greater; _TP _US pq = priority_queue; _TP _US pqg = priority_queue, gr>; #define int int64_t #define itn int64_t #define uset unordered_set #define umap unordered_map _US i8 = int8_t; _US u8 = uint8_t; _US i16 = int16_t; _US u16 = uint16_t; _US i32 = int32_t; _US u32 = uint32_t; _US i64 = int64_t; _US u64 = uint64_t; _US intw = __int128_t; _US uintw = __uint128_t; _US f32 = float; _US f64 = double; _US vi = vc; _US vb = vc; _US pi = pair; _US str = string; _US vs = vc; _US VI = vv; _US VB = vv; _US pqgp = pqg; _CC str yes{"Yes\n"}; _CC str no{"No\n"}; _CC int inf = 1ll << 60; _CC int minf = -inf; _CC array dc = {{{1, 0}, {0, 1}, {-1, 0}, {0, -1}, {1, 1}, {1, -1}, {-1, 1}, {-1, -1}}}; _CC array mods{998244353, 998244853, 1000000007, 1000000009, 1000000021, 1000000033}; inline int ceil(_CT int a, const int b) { return (a + b - 1) / b; } inline int floor(const int a, const int b) { return a / b - (a % b && (a ^ b) < 0); } #define UINT unsigned_integral #define SINT signed_integral #define MUT make_unsigned_t #define PPCNT popcount #define MSB countl_zero #define LSB countr_zero _TP int pcnt(T p){ return PPCNT(p); } _TP int pcnt(T p){ return PPCNT(MUT(p)); } _TP int zcnt(T p){ return MSB(p); } _TP int zcnt(T p){ return MSB(MUT(p)); } _TP int lsb(T p){ return LSB(p); } _TP int lsb(T p){ return LSB(MUT(p)); } void IOset(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); cout<>n; vi a(n);for(int&x:a)cin>>x; int ans=inf; for(int i=0;i>b; for(int j=0;j({j}))); for(int i=2;i*2<=n;i++){ auto old=move(b); b.clear(); auto itr=old.rbegin(); for(;itr!=old.rend();itr++){ for(int j=0;jse.contains(j)){ settmp=itr->se; tmp.ins(j); b.ins(mp(itr->fi+a[j],move(tmp))); } } } for(auto itr=b.begin();itr!=b.end();){ auto next=b.upper_bound(itr->fi); auto jtr=itr; for(jtr++;jtr!=next;jtr++){ bool out=true; for(auto const&x:itr->se){ if(jtr->se.contains(x)){ out =false; break; } } if(out){ ans=0; cout<<0<fi); jtr=next; for(jtr++;jtr!=nnext;jtr++){ bool out=true; for(auto const&x:itr->se){ if(jtr->se.contains(x)){ out =false; break; } } if(out) ans=min(ans,jtr->fi-itr->fi); } itr=next; } } cout<