#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;
  map<int, int> mp;
  for (int i = (int)0; i < (int)n; ++i) {
    cin >> d;
    if (n == 1) {
      cout << d << "\n";
      return;
    }
    mp[d]++;
  }
  vector<int> v;
  if (n >= 24) {
    cout << 0 << "\n";
  }
  for (auto x : mp) {
    if (x.second > 2) {
      cout << 0 << "\n";
      return;
    }
    for (int i = (int)0; i < (int)x.second; ++i) v.push_back(x.first);
  }
  v.push_back(0);
  vector<int> w(n + 1);
  for (int i = 0; i < (1 << n); ++i) {
    for (int j = (int)0; j < (int)n + 1; ++j) {
      if ((1 << j) & i)
        w[j] = 24 - v[j];
      else
        w[j] = v[j];
    }
    int minv = 30;
    for (int j = (int)0; j < (int)n; ++j) {
      for (int k = j + 1; k < n + 1; ++k) {
        minv = min(minv, abs(w[j] - w[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;
}
