#include<bits/stdc++.h>
const int maxn = 18;
typedef long long ll;
ll dp[maxn][maxn][1 << maxn];
int a[maxn],n;
inline ll dfs(int l,int r,int lv,int rv,int st){
	if(~dp[l][r][st]) return dp[l][r][st];
	if(l + 1 == r) return (ll) lv * a[l] + (ll) rv * a[r];
	ll & ans = dp[l][r][st] = 1e18;
	for(int i = l + 1;i < r;++i){
		ans = std::min(ans,dfs(l,i,lv,lv + rv,st << 1) + dfs(i,r,lv + rv,rv,st << 1 | 1) - a[i] * ll(lv + rv));
	}
	return ans;
}
int main(){
	std::cin >> n, memset(dp,-1,sizeof dp);
	for(int i = 0;i < n;++i) std::cin >> a[i];
	std::cout << dfs(0,n - 1,1,1,1) << '\n';
}
