#include <iostream>
#include <algorithm>
using namespace std;
#define int long long
#define R register
int a[20];
int n;
inline int dfs(int l,int r,int cl,int cr)
{
	if(r-l<2) return 0;
	int res=(1ll<<60);
	for(R int i=l+1;i<=r-1;i++)
		res=min(res,dfs(l,i,cl,cl+cr)+dfs(i,r,cl+cr,cr)+(cl+cr)*a[i]);
	return res;
}
signed main()
{
	cin>>n;
	for(R int i=1;i<=n;i++) cin>>a[i];
	cout<<dfs(1,n,1,1)+a[1]+a[n]<<endl;
}