#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
ll a[18];

ll solve (int l, int r, int xl, int xr) {
    if (l+1 == r) return 0;
    ll ret = linf;
    for (int i = l+1; i < r; i++) {
        ret = min(ret, solve(l, i, xl, xl+xr) + solve(i, r, xl+xr, xr) + a[i] * (xl+xr));
    }
    return ret;
}

int main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    cout << solve(0, n-1, 1, 1) + a[0] + a[n-1] << endl;
}
