#include <bits/stdc++.h>

const int N = 20;

int n, A[N];
std::map<std::pair<int, int>, long long> map[N][N];

long long dfs(int l, int r, int L, int R) {
  if (r == l + 1) return 0;
  if (map[l][r].count({ L, R }))
    return map[l][r][{ L, R }];
  long long ret = 1e18;
  for (int k = l + 1; k < r; ++k)
    ret = std::min(ret, dfs(l, k, L, L + R) + dfs(k, r, L + R, R)
      + 1ll * (L + R) * A[k]);
  return map[l][r][{ L, R }] = ret;
}

int main() {
  std::cin >> n;
  for (int i = 1; i <= n; ++i)
    std::cin >> A[i];
  std::cout << dfs(1, n, 1, 1) + A[1] + A[n] << std::endl;
  return 0;
}
