#include<stdio.h>
#include<bits/stdc++.h>
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;

int n;
int a[21];

inline long long DFS(int l,int r,int x,int y)
{
	if(l>=r-1) return 0;
	register long long res=1e18;
	for(register int i=l+1;i<r;++i)
	{
		register long long temp=DFS(l,i,x,y+x)+DFS(i,r,x+y,y)+1ll*a[i]*(x+y);
		res=min(res,temp);
	}
	return res;
}

int main(void)
{
	scanf("%d",&n);
	for(register int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	printf("%lld\n",a[1]+a[n]+DFS(1,n,1,1));
	return 0;
}