/**
 *    author:  tourist
 *    created: 14.07.2019 15:43:48       
**/
#include <bits/stdc++.h>

using namespace std;

vector<long long> a;
int n;

long long Go(int from, int to, long long ca, long long cb) {
  if (to - from == 1) {
    return 0;
  }
  long long best;
  best = (long long) 1e18;
  for (int i = from + 1; i < to; i++) {
    long long cur = a[i] * (ca + cb) + Go(from, i, ca, ca + cb) + Go(i, to, ca + cb, cb);
    best = min(best, cur);
  }
  return best;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << Go(0, n - 1, 1, 1) + a[0] + a[n - 1] << '\n';
  return 0;
}
