#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n, A[20];
unordered_map<int, ll> mem[20][20];
ll solve(int l, int r, int a, int b) {
  if (r - l == 1) return 1LL * a * A[l] + 1LL * b * A[r];
  int hsh = a * 100000 + b;
  if (mem[l][r].count(hsh)) return mem[l][r][hsh];
  ll ans = 1e18;
  for (int j = l + 1; j < r; ++j) {
    ans = min(
        solve(l, j, a, a + b) + solve(j, r, a + b, b) - 1LL * A[j] * (a + b),
        ans);
  }
  mem[l][r][hsh] = ans;
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", A + i);
  printf("%lld\n", solve(1, n, 1, 1));
}
