#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const ll MAX = 3e2 + 5, mod = 998244353, inf = 0x3f3f3f3f3f3f3f3f;
int n;
ll a[30];
ll solve(int l, int r, int p1, int p2) {
  if (l + 1 == r) return 0;
  ll temp = inf;
  for (int i = l + 1; i < r; i++) {
    temp = min(temp, solve(l, i, p1, p1 + p2) + solve(i, r, p1 + p2, p2) +
                         a[i] * (p1 + p2));
  }
  return temp;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  cout << solve(1, n, 1, 1) + a[1] + a[n];
}
