#include<bits/stdc++.h>
#define int long long
using namespace std;

int n,a[20];
map<pair<int,int>,int>dp[22][22];

int dfs(int l,int r,int mul_l,int mul_r){
	if(l>r)return 0;
	if(dp[l][r].count(make_pair(mul_l,mul_r)))return dp[l][r][make_pair(mul_l,mul_r)];
	int &ret=dp[l][r][make_pair(mul_l,mul_r)];ret=1e18;
	for(int mid=l;mid<=r;mid++){
		ret=min(ret,dfs(l,mid-1,mul_l,mul_l+mul_r)+dfs(mid+1,r,mul_l+mul_r,mul_r)+a[mid]*(mul_l+mul_r));
	}
//	cerr<<l<<" "<<r<<" "<<mul_l<<" "<<mul_r<<" "<<ret<<endl;
	return ret;
}

signed main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	cout<<a[1]+a[n]+dfs(2,n-1,1,1)<<endl;
	return 0;
}