#include <bits/stdc++.h>
using namespace std;
const long long BIGER = 1000000000000000;
const int BIG = 1000000000;
const int MOD = 1000000007;
int a[101];
int tm[101];
int nkvd(int tmie);
int kgb(int tmie);
int mingap(int m, int tmie) {
  int mn = BIG;
  for (int i = 0; i < m; i++) {
    mn = min(mn, kgb(nkvd(tm[i] - tmie)));
  }
  return mn;
}
int nkvd(int tmie) { return (tmie + 24) % 24; }
int kgb(int tmie) { return min(24 - tmie, tmie); }
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] = kgb(a[i]);
  }
  int mn = BIG;
  for (int i = 1; i <= n; i++) {
    if (mingap(i, nkvd(tm[i - 1] + a[i])) > mingap(i, nkvd(tm[i - 1] - a[i]))) {
      tm[i] = nkvd(tm[i - 1] + a[i]);
    } else {
      tm[i] = nkvd(tm[i - 1] - a[i]);
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      mn = min(mn, kgb(nkvd(tm[i] - tm[j])));
    }
  }
  cout << mn;
  return 0;
}
