#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz=20;
int n;
struct node{
    int l,r,fl,fr;
    const bool operator<(const node &p)const{
        if(l!=p.l) return l<p.l;
        if(r!=p.r) return r<p.r;
        if(fl!=p.fl) return fl<p.fl;
        if(fr!=p.fr) return fr<p.fr;
    }
};
ll a[sz];
ll g[sz][sz][611][611];
map<node,ll>dp;
ll f(int l,int r,int fl,int fr){
    if(l+1==r) return 0;
    if(fl<611&&fr<611){
        if(g[l][r][fl][fr]) return g[l][r][fl][fr];
    }
    else if(dp[(node){l,r,fl,fr}]) return dp[(node){l,r,fl,fr}];
    ll ret=1e18;
    ll sum=fl+fr;
    for(int i=l+1;i<=r-1;i++){
        ret=min(ret,sum*a[i]+f(l,i,fl,sum)+f(i,r,sum,fr));
    }
    if(fl<611&&fr<611) return g[l][r][fl][fr]=ret;
    else return dp[(node){l,r,fl,fr}]=ret;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    printf("%lld\n",a[1]+f(1,n,1,1)+a[n]);
} 