#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = 1e12;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  n++;
  vector<long long> d(n);
  d[0] = 0;
  for (long long i = 1; i < n; i++) cin >> d[i];
  sort(d.begin(), d.end());
  long long ans = INF, ans2 = INF;
  for (long long i = 0; i < n; i++) {
    long long next = d[(i + 1) % n];
    long long now = d[i];
    if (i % 2) now = 24 - now;
    ans2 = min(ans2, abs(next - now));
    if (i % 2) next = 24 - next;
    ans = min(ans, abs(next - d[i]));
  }
  cout << min(ans, ans2) << endl;
}
