#include <bits/stdc++.h>
using namespace std;
static const int64_t INFL = 0x3F3F3F3F3F3F3F3FLL;
struct Solution {
  void solve(std::istream& in, std::ostream& out) {
    int64_t n;
    in >> n;
    n++;
    vector<int64_t> d(n);
    vector<vector<int64_t> > dist(n, vector<int64_t>(n));
    for (int i = 1; i < n; i++) {
      in >> d[i];
    }
    int64_t ans = INFL;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i == j) {
          continue;
        }
        dist[i][j] = max(
            max(abs(d[i] - d[j]) % 24, abs((24 - d[i]) - (24 - d[j])) % 24),
            max(abs((24 - d[i]) - d[j]) % 24, abs(d[i] - (24 - d[j])) % 24));
        ans = min(ans, dist[i][j]);
      }
    }
    out << ans << '\n';
  }
};
void solve(std::istream& in, std::ostream& out) {
  out << std::setprecision(12);
  Solution solution;
  solution.solve(in, out);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  istream& in = cin;
  ostream& out = cout;
  solve(in, out);
  return 0;
}
