#include <bits/stdc++.h>
using namespace std;
int N, D[50], ans, a, b;
int iabs(int a) { return a < 0 ? -a : a; }
vector<int> v;
int main() {
  cin >> N;
  for (int i{}; i < N; ++i) cin >> D[i];
  v.emplace_back(0);
  a = D[0], b = D[0] ? 24 - D[0] : 0;
  ans = max(a, b), v.emplace_back(max(a, b));
  for (int i{1}; i < N; ++i) {
    int r1, r2;
    r1 = r2 = numeric_limits<int>::max();
    for (auto& t : v)
      r1 = min(r1, iabs(t - D[i])),
      r2 = min(r2, iabs(D[i] ? t - 24 + D[i] : t));
    ans = min(ans, max(r1, r2));
    v.emplace_back(r1 < r2 ? (D[i] ? 24 - D[i] : D[i]) : D[i]);
  }
  cout << ans << endl;
}
