#include <bits/stdc++.h>
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
void solve() {
  int n;
  cin >> n;
  int d, ans = 0, dmin = 30;
  map<int, int> mp;
  for (int i = (int)0; i < (int)n; ++i) {
    cin >> d;
    dmin = min(d, dmin);
    mp[d]++;
  }
  vector<int> v, w;
  for (auto x : mp) {
    if (x.second > 2) {
      cout << 0 << "\n";
      return;
    } else if (x.second == 2) {
      v.push_back(x.first);
      v.push_back(24 - x.first);
    } else
      w.push_back(x.first);
  }
  int m = w.size();
  vector<int> w2(m);
  if (m)
    for (int i = 0; i < (1 << m); ++i) {
      for (int j = (int)0; j < (int)m; ++j) {
        if ((1 << j) & i)
          w2[j] = 24 - w[j];
        else
          w2[j] = w[j];
      }
      for (int j = (int)0; j < (int)v.size(); ++j) w2.push_back(v[j]);
      int minv = dmin;
      for (int j = (int)0; j < (int)m - 1; ++j) {
        for (int k = j + 1; k < m; ++k) {
          minv = min(minv, abs(w2[j] - w2[k]));
        }
      }
      ans = max(ans, minv);
    }
  else {
    int minv = dmin;
    for (int j = (int)0; j < (int)v.size() - 1; ++j)
      for (int k = j + 1; k < v.size(); ++k) minv = min(minv, abs(v[j] - v[k]));
    ans = max(ans, minv);
  }
  cout << ans << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  solve();
  return 0;
}
