Maximum Subsequence

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

For a sequence a_1...na\_{1...n}, define f(a)f(a) as f(a)=max_1lrn_i=lra_i.f(a) = \max\limits\_{1 \le l \le r \le n} \sum\limits\_{i = l}^{r} a\_i\text{.}

Given a sequence b_1...nb\_{1...n}, you need to permute b_1...nb\_{1...n} to get b_1...nb'\_{1...n} and minimize f(b)f(b').

입력

The first line contains a single integer nn (1n161 \le n \le 16).

The second line contains nn integers a_1...na\_{1...n} (a_i105|a\_i| \le 10^5).

출력

Output the minimum possible f(b)f(b').