#include <bits/stdc++.h>
using namespace std;
int n, a[18];
const long long inf = 1e18;
map<pair<int, int>, long long> mp[18][18];
long long solve(int l, int r, int x, int y) {
  map<pair<int, int>, long long>::iterator it =
      mp[l][r].find(pair<int, int>(x, y));
  if (it != mp[l][r].end()) return it->second;
  if (l == r - 1) return mp[l][r][pair<int, int>(x, y)] = 0;
  long long t = inf;
  for (int m = l + 1; m < r; m++)
    t = min(t, solve(l, m, x, x + y) + solve(m, r, x + y, y) +
                   1ll * a[m] * (x + y));
  return mp[l][r][pair<int, int>(x, y)] = t;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  printf("%lld\n", solve(0, n - 1, 1, 1) + a[0] + a[n - 1]);
  return 0;
}
