#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);
  ans = 24;
  for (int i{}; 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(t - 24 + D[i]));
    ans = min(ans, max(r1, r2));
    v.emplace_back(r1 < r2 ? 24 - D[i] : D[i]);
  }
  cout << min(ans, *min_element(D, D + N)) << endl;
}
