#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void _err(std::ostream& cerr, istream_iterator<string> it) { cerr << endl; }
template <typename T, typename... Args>
void _err(std::ostream& cerr, istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "  ";
  _err(cerr, ++it, args...);
}
const double pi = 2 * acos(.0);
const int inf = 0x3f3f3f3f;
const ll mod = (ll)(1e9) + 7;
const double eps = 1e-10;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
  std::fill((T*)array, (T*)(array + N), val);
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T> V) {
  for (auto v : V) os << v << " ";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const set<T> V) {
  for (auto v : V) os << v << " ";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, const deque<T> V) {
  for (auto v : V) os << v << " ";
  return os;
}
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;
}
class CTimeGap {
 public:
  void solve(std::istream& cin, std::ostream& cout, std::ostream& cerr) {
    int N;
    vector<int> a;
    cin >> N;
    a.emplace_back(0);
    for (__typeof(N) i = 0, _len = (N); i < (_len); i += 1)
      a.emplace_back(({
        int t;
        cin >> t;
        t;
      }));
    int ans = -1;
    for (__typeof((1LL << (12))) mask = 0, _len = ((1LL << (12)));
         mask < (_len); mask += 1) {
      vector<int> t(a);
      int mi = 25;
      for (__typeof(12) end = 12, begin = 1, i = (begin) - ((begin) > (end));
           i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
        if (mask & (1 << i)) {
          auto it = find((t).begin(), (t).end(), i);
          if (it != t.end()) {
            t.erase(it);
            t.emplace_back(24 - i);
          }
        }
      for (__typeof(((int)(t).size()) - 1) i = 0,
                                           _len = (((int)(t).size()) - 1);
           i < (_len); i += 1)
        Chmin(mi, t[i + 1] - t[i]);
      Chmax(ans, mi);
    }
    cout << (ans) << endl;
  }
};
int main() {
  CTimeGap solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  std::ostringstream err;
  in.tie(0);
  ios::sync_with_stdio(0);
  solver.solve(in, out, err);
  return 0;
}
