#include <iostream>
#define ll long long
using namespace std;

ll a[20], mult[20];
ll solve(int left, int right){
	if(left+1==right) return 0;
	ll mn=(ll) 1e13;
	for(int i=left+1; i<right; ++i){
		mult[i]=mult[left]+mult[right];
		mn=min(mn, a[i]*mult[i]+solve(left, i)+solve(i, right));
		mult[i]=0;
	}
	return mn;
}


int main() {
	int N;
	cin >> N;
	for(int i=0; i<N; ++i) cin >> a[i];
	mult[0]=mult[N-1]=1;
	cout << a[0]+a[N-1]+solve(0, N-1) << endl;
	return 0;
}