#include using namespace std; using ll = long long; using ull = unsigned long long; using P = pair; using T = tuple; using Graph = vector>; #define pb push_back #define F first #define S second #define rep(i,a) for(int i = 0; i < a; ++i) #define rrep(i, a, b) for(int i = a; i < b; ++i) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define mp(x, y) make_pair(x,y) template bool chmax(T &a,T b){if(a bool chmin(T &a,T b){if(a>b){a=b; return true;} return false;} const int INF = 1<<30; const ll LINF = 1LL<<60; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector a(n); rep(i,n) cin >> a[i]; vector dp(1<