#include<bits/stdc++.h>
using namespace std;
int n, num[20];
long long dfs(int l, int r, int x, int y)
{
	if (l + 1 >= r)return 0;
	long long res = 1e18;
	for (int i = l + 1; i <= r - 1; i++)
		res = min(res, dfs(l, i, x, x + y) + dfs(i, r, x + y, y) + 1LL * (x + y) * num[i]);
	return res;
}
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> num[i];
	cout << num[1] + num[n] + dfs(1, n, 1, 1) << endl;
	return 0;
}