#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<algorithm>
#include<ctime>
using namespace std;
#define ll long long
int n, A[25];
ll Getans(int l, int r, ll L, ll R)
{
	if (l + 1 == r)
		return L * A[l] + R * A[r];
	ll ret = 0x7f7f7f7f7f7f7f7fll;
	for (int i = l + 1; i < r; i++)
		ret = min(Getans(l, i, L, L + R) + Getans(i, r, L + R, R) - A[i] * (L + R), ret);
	return ret;
}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &A[i]);
	printf("%lld\n", Getans(1, n, 1, 1));
}
