#include <cstdio>
#include <algorithm>

using namespace std;

#define forn(i, n) for (int i = 0; i < (n); i++)

const int maxn = 20, inf = (int)1e9;

int n, a[maxn], f[1 << maxn];

int NewMask( int mask, int i )
{
  forn(j, 3)
    mask |= 1 << ((i + j) % n);
  return mask;
}            

int go( int mask )
{
  if (mask == (1 << n) - 1)
    return 0;
  int &res = f[mask];
  if (res)
    return res;

  int tmp = inf, mask1;
  forn(i, n)
    if (!((mask >> i) & 1))
      res += a[i];
  forn(i, n)
    if ((mask1 = NewMask(mask, i)) != mask)
      tmp = min(tmp, go(mask1));
  return res += tmp;
}

int main()
{
  scanf("%d", &n);
  forn(i, n)
    scanf("%d", &a[i]);

  int ans = inf;
  forn(i, n)
    ans = min(ans, go(NewMask(0, i)));
  printf("%d\n", ans);
  return 0;
}