#include <bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const long long MOD = 1000000007;
template <typename T>
T &chmin(T &a, const T &b) {
  return a = min(a, b);
}
template <typename T>
T &chmax(T &a, const T &b) {
  return a = max(a, b);
}
long long dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
signed main(void) {
  long long n;
  cin >> n;
  vector<long long> d(n + 1);
  for (long long i = (long long)0; i < (long long)n; ++i) cin >> d[i];
  if (n == 1) {
    cout << min(d[0], 24 - d[0]) << endl;
    return 0;
  }
  d[n] = 0;
  sort(d.begin(), d.end());
  long long lim = INF;
  for (long long i = (long long)0; i < (long long)n + 1; ++i) {
    for (long long j = (long long)i + 1; j < (long long)n + 1; ++j) {
      if (d[i] == d[j]) chmin(lim, 24 - d[j] - d[i]);
    }
  }
  d.erase(unique(d.begin(), d.end()), d.end());
  vector<long long> v;
  long long m = d.size();
  long long ret = 0;
  for (long long i = (long long)0; i < (long long)1 << m; ++i) {
    v.clear();
    for (long long j = (long long)0; j < (long long)m; ++j) {
      if (i & 1 << j) {
        v.push_back(d[j]);
      } else {
        v.push_back((24 - d[j]) % 24);
      }
    }
    sort(v.begin(), v.end());
    long long res = INF;
    for (long long j = (long long)0; j < (long long)v.size(); ++j) {
      for (long long k = (long long)j + 1; k < (long long)v.size(); ++k) {
        chmin(res, min(v[k] - v[j], 24 - (v[k] - v[j])));
      }
    }
    chmax(ret, res);
  }
  cout << min(lim, ret) << endl;
  return 0;
}
