#include <cstdio>
#include <algorithm>
#include <map>

typedef long long LL;
const int MN = 20;

int N, A[MN];

LL F(int l, int r, int cl, int cr) {
	if (l > r) return 0;
	LL ans = 0x3f3f3f3f3f3f3f3f;
	for (int i = l; i <= r; ++i)
		ans = std::min(ans, F(l, i - 1, cl, cl + cr) + (LL)A[i] * (cl + cr) + F(i + 1, r, cl + cr, cr));
	return ans;
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%d", &A[i]);
	N -= 2;
	printf("%lld\n", F(1, N, 1, 1) + A[0] + A[N + 1]);
	return 0;
}