#include <bits/stdc++.h>
using namespace std;
int main() {
  size_t N;
  cin >> N;
  vector<size_t> k(13), l(25);
  k[0] = 1;
  for (size_t i = 0, j; i < N; ++i) {
    cin >> j;
    if (l[24 - j]) return 0 & puts("0");
    l[j] = l[24 - j] = k[j];
    k[j] = 1;
  }
  vector<size_t> D, C;
  for (size_t i = 0; i < 13; ++i)
    if (k[i] ^ l[i]) D.push_back(i);
  for (size_t i = 0; i < 24; ++i)
    if (l[i]) C.push_back(i);
  auto d = D.size();
  vector<size_t> a(d + C.size());
  size_t ans = 0, K = 30 * !l[0];
  for (const auto i : C)
    for (const auto j : C)
      if (i ^ j) K = min(K, max(i, j) - min(i, j));
  for (size_t i = 0, j; i < 1 << d; ans = max(j, ans)) {
    j = K;
    if (++i && d) (D[__builtin_ctzl(i)] *= -1) += 24;
    for (const auto ii : D)
      for (const auto jj : D)
        if (ii ^ jj) j = min(j, max(ii, jj) - min(ii, jj));
    for (const auto ii : D)
      for (const auto jj : C)
        if (ii ^ jj) j = min(j, max(ii, jj) - min(ii, jj));
  }
  cout << ans << endl;
  return 0;
}
