#include <bits/stdc++.h>
using namespace std;

const int N = 20;

typedef long long LL;

int a[N];

LL dfs(int l, int r, int tl, int tr) {
    if (l > r) return 0;
    LL res = 1e18; 
    for (int i = l; i <= r; i++) 
        res = min(res, dfs(l, i - 1, tl, tl + tr) + dfs(i + 1, r, tl + tr, tr) + (LL)a[i] * (tl + tr));
    return res;
}

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