#include <bits/stdc++.h>
using namespace std;
template <typename _Tp>
inline void IN(_Tp& x) {
  char ch;
  bool flag = 0;
  x = 0;
  while (ch = getchar(), !isdigit(ch))
    if (ch == '-') flag = 1;
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  if (flag) x = -x;
}
int n;
long long a[25];
long long solve(int l, int r, long long x, long long y) {
  if (r - l <= 1) return 0;
  long long ans = 1e18;
  for (int i = l + 1; i <= r - 1; ++i)
    ans = min(ans,
              solve(l, i, x, x + y) + solve(i, r, x + y, y) + (x + y) * a[i]);
  return ans;
}
int main() {
  IN(n);
  for (int i = 1; i <= n; ++i) IN(a[i]);
  printf("%lld\n", a[1] + a[n] + solve(1, n, 1, 1));
  return 0;
}
