#include <bits/stdc++.h>
using namespace std;
struct Grid {
  long long x, y, t;
};
struct Edge {
  long long to, cost;
};
struct Graph {
  vector<vector<Edge>> E;
  int V;
  const long long Inf = 1e18;
  const int MAX_V = 201010;
  vector<long long> d;
  Graph(int n) : E(n) {
    d.resize(MAX_V);
    E.resize(n);
    V = n;
  }
  void init() {
    for (int i = 0; i < MAX_V; i++) d[i] = Inf;
  }
  void add_edge(long long from, long long to, long long cost) {
    E[from].push_back({to, cost});
  }
};
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  vector<long long> hog(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> hog[i];
  }
  long long mi = 1e9;
  for (int i = 0; i < n + 1; i++) {
    if (i % 2) {
      mi = min(mi, (abs((24 - hog[i]) - hog[(i + 1) % (n + 1)])) % 24);
    } else {
      mi = min(mi, (abs(hog[i] - (24 - hog[(i + 1) % (n + 1)]))) % 24);
    }
  }
  long long mi2 = 1e9;
  for (int i = 0; i < n + 1; i++) {
    if (i % 2 == 0) {
      mi2 = min(mi2, (abs((24 - hog[i]) - hog[(i + 1) % (n + 1)])) % 24);
    } else {
      mi2 = min(mi2, (abs((hog[i] - (24 - hog[(i + 1) % (n + 1)]))) % 24));
    }
  }
  cout << max(mi, mi2) << endl;
  return 0;
}
