#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<long long>;
using pii = pair<long long, long long>;
const long long DX[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0},
                DY[9] = {-1, 0, 1, 0, -1, 1, 1, -1, 0};
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (auto i = (begin(v)); i != (end(v)); ++i)
    os << *i << (i == end(v) - 1 ? "" : "\n");
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto i = (begin(v)); i != (end(v)); ++i) is >> *i;
  return is;
}
template <class T>
istream &operator>>(istream &is, pair<T, T> &p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
using heap = priority_queue<T, vector<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(15) << fixed;
  }
} before_main_function;
long long gap(long long a, long long b) {
  if (a > b) swap(a, b);
  b -= a;
  return min(b, 24 - b);
}
signed main() {
  long long N;
  cin >> N;
  vector<long long> D(N + 1);
  D[0] = 0;
  for (long long i = 0, ilen = (long long)(N); i < ilen; ++i) {
    cin >> D[i + 1];
    D[i + 1] = min(D[i + 1], 24 - D[i + 1]);
  }
  sort(begin(D), end(D));
  long long ans = (1001001001001001001ll);
  for (long long i = 1, ilen = (long long)(N + 1); i < ilen; ++i) {
    if (i % 2) {
      chmin(ans, gap(24 - D[i], D[i - 1]));
    } else {
      chmin(ans, gap(D[i], 24 - D[i - 1]));
    }
  }
  cout << ans << "\n";
  return 0;
}
