/*
                     .:*+=%@@@@@@=-.
                 .:=@#@@@#@@#######%==*.
              .-=####@######%*-.....:%##%.
            .*@###########%+:--........-%@-
          .*@##############@+--.........-:%-
        .+##################@==%%%%=+*:----+.
      .-@####################%++%@@@@@=+**%@@*
      .%###################@%%@@@###@%+:--%@@%.
     -@###################@%%%%*::*%++:-----=@+.
    -#####################@%=++++++*:-------.-=:
   .+####################@%++*::-:::--::*:::***=:
   .@#####################%=++*::::-:::++*=##@@#@-
  ..#####################@%%=++**:::::**+%@#@%%##-..
   .%####################@@%=+++*+****::*=@######@.
  .=######################@%%==+==++**+=@%@##@###+:...
  -#######################@@@%%%===++=@@@%=++===*::--...
  -########################@@@@@@@%==%%=++==@@:::::*:--.
..:#########################@@@@@@%%======++++::-..:-.--...
%#############################@###@%%@@%==%=%*----.--.::---.
#############################################*-:*:-:---*---- .
#############################################*--*--:---*---:-.
#############################################+--::--::-*::-::.
###########################################+:*-.---.---.:---*-..
###########################################**:-----------------.
##########################################@::**:--::::::--:::::-
###########################################:--:*:::::::::**::*+*
###########################################=:::***::::::**:::*+*
############################@@@@@@#########@+****::::********+++
############################@%%%%%@@@@@@@###%+***::::::::***+==+
############################@%%%%%%%%%%%@####=+:::-::::-::*+=%%+
#############################@%%%%%%%%%%@#####=::--------:*=%@%+
%###########################@%%%%==%%%%%%@##@#=:------..-:+%@@%=
----------------------------------------------
--------------------------------------------
----------------------------------------------
--------------------------------------------
----------------------------------------------

         o###########oo
      o##"          ""##o
    o#"                "##
  o#"                    "#o
 #"  ##              ##   "##
#"                          ##
#  ###################       #
#                            #
#                            #
#                            #
#                            #
#                            #
#                            #
#o                           #
"#o                         ##
 "#o                       ##
  "#o                    o#"
   "#o                  ##
     "#o              o#"
       "#ooo      ooo#######oo
        ###############   "######o
     o###""        "###o      # ###
   o###o     oooo    ###    oo####"
 o###**#     #**#   ############"
 ""##""""""""""###########    #
    # oooooooo#"#**     ##    #
    # #       # # **    ##    #
    #o#       #o#  *****###ooo#
                        ##
                        ##   o###o
                        ## o##***##
               o########## #***#**##o
             o##"   ""###  #***##***#
 o#######o  ###   oo####   ##**####*#
o##"  ""#############""     ##****###
##"         ##              ##*##*###
##          ###              ##### ##
##           ###              # ##  #
##            ##                 #
##             ##
##             ###
##              ###oo
###              ""###
 ###
  ###
*/

///YEAH IM THE BEST I'VE EVER WAS

///SO HAPPY

#include <bits/stdc++.h>

#define fr first

#define sc second

#define m_p make_pair

#define unique(a) a.resize(unique(a.begin(), a.end()) - a.begin())

#define low_bo(a, x) lower_bound(a.begin(), a.end(), x) - a.begin()

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

//gp_hash_table<int, int> table;

//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
//float __attribute__((aligned(32)))

/*char memory[(int)1e8];

char memorypos;

inline void * operator new(size_t n){
    char * ret = memory + memorypos;
    memorypos += n;
    return (void *)ret;
}

inline void operator delete(void *){}
*/

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef long double ld;

typedef unsigned int uint;

ll sqr(ll x){
    return x * x;
}

int mysqrt(ll x){
    int l = 0, r = 1e9 + 1;
    while (r - l > 1){
        int m = (l + r) / 2;
        if (m * (ll)m <= x)
            l = m;
        else
            r = m;
    }
    return l;
}

mt19937 rnd(1227);

mt19937_64 rndll(12365);

int gcd(int a, int b){
    return a ? gcd(b % a, a) : b;
}

int gcdex(int a, int b, int &x, int &y){
    if (a == 0){
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int ret = gcdex(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return ret;
}

const int Mod = 1e9 + 7;

int Bpow(int x, int y){
    int ret = 1;
    int w = x;
    while (y){
        if (y & 1)
            ret = (ret * (ll)w) % Mod;
        w = (w * (ll)w) % Mod;
        y >>= 1;
    }
    return ret;
}

int Bdiv(int x){
    int a, b;
    gcdex(x, Mod, a, b);
    if (a < 0)
        a += Mod;
    return a;
}

int Bdiv(int x, int y){
    return (x * (ll)Bpow(y, Mod - 2)) % Mod;
}

inline int ad(int x, int y){
    return x + y >= Mod ? x + y - Mod : x + y;
}

inline int dif(int x, int y){
    return x - y < 0 ? x - y + Mod : x - y;
}

inline int mul(int x, int y){
    return (x * (ll)y) % Mod;
}

int inv(int a){
    int b = Mod, x = 0, y = 1;
    while (a){
        int t = b / a;
        b -= a * t;
        x -= t * y;
        swap(a, b);
        swap(x, y);
    }
    if (x < 0)
        x += Mod;
    return x;
}

void setmin(int &x, int y){
    x = min(x, y);
}

void setmax(int &x, int y){
    x = max(x, y);
}

void setmin(ll &x, ll y){
    x = min(x, y);
}

void setmax(ll &x, ll y){
    x = max(x, y);
}

const ll llinf = 1e18 + 100;

const double eps = 1e-9;

const int maxn = 2e5 + 100, maxw = 1e6 + 100, inf = 2e9 + 100, mod = 1e9 + 7;

vector<vector<ll> > q[16][16];

int a[18];

int main() {
    #ifdef ONPC
    freopen("a.in", "r", stdin);
    freopen("a.out", "w", stdout);
    #else
    //freopen("markchain.in", "r", stdin);
    //freopen("markchain.out", "w", stdout);
    #endif // ONPC
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    if (n == 2) {
        cout << a[0] + a[1];
        return 0;
    }
    vector<int> fib(20);
    fib[1] = fib[2] = 1;
    for (int i = 3; i <= 17; i++)
        fib[i] = fib[i - 2] + fib[i - 1];
    ll S = 0;
    for (int i = 0; i < n - 2; i++)
        for (int j = 0; j + i < n - 2; j++) {
            q[i][j].resize(fib[n - 1 - i], vector<ll>(fib[n - 1 - i], llinf));
            int l = j + 1, r = l + i;
            for (int x = 0; x < fib[n - 1 - i]; x++)
                for (int y = 0; y < fib[n - 1 - i]; y++)
                    if (i == 0)
                        q[i][j][x][y] = a[l] * (ll)(x + y + 2);
                    else
                        for (int k = l; k <= r; k++) {
                            ll w = a[k] * (ll)(x + y + 2);
                            if (k > l && q[k - l - 1][j].size() > x + y + 1)
                                w += q[k - l - 1][j][x][x + y + 1];
                            if (k < r && q[r - k - 1][k].size() > x + y + 1)
                                w += q[r - k - 1][k][x + y + 1][y];
                            setmin(q[i][j][x][y], w);
                        }
        }
    cout << q[n - 3][0][0][0] + a[0] + a[n - 1];
}
/*
int p[maxn], n;

vector<int> e[maxn];

bool good;

int score(int v) {
    return v < n ? v + 1 : v - n + 1;
}

int dfs(int v, int st, int w = 0, int par = -1) {
    if (v == st + n) {
        if (w == 0)
            return 1;
        else
            return 2;
    }
    for (int i : e[v])
        if (i != par) {
            int o = dfs(i, st, w ^ score(v), v);
            if (o)
                return o;
        }
    return 0;
}

void go() {
    vector<int> p(2 * n);
    iota(p.begin(), p.end(), 0);
    do {
        for (int i = 0; i < 2 * n; i++)
            e[i].clear();
        for (int i = 1; i < 2 * n; i++) {
            e[p[i - 1]].push_back(p[i]);
            e[p[i]].push_back(p[i - 1]);
        }
        for (int i = 0; i < n; i++)
            if (dfs(i, i) == 2)
                return;
        for (int i = 0; i < 2 * n; i++)
            cout << p[i] + 1 << ' ';
        for (int i = 0; i < n; i++)
            if (dfs(i, i) == 2)
                return;
        exit(0);
    } while (next_permutation(p.begin(), p.end()));
}*/


Measured memory_bytes: 498264