#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int mindiff(vector<int>& a) {
  sort(a.begin(), a.end());
  int ans = 100;
  for (int i = 0; i < a.size(); ++i) {
    chmin(ans, abs(a[(i + 1) % a.size()] - a[i]));
  }
  return ans;
}
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; ++i) cin >> d[i];
  if (N >= 24) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for (int bit = 0; bit < 1 << N; ++bit) {
    vector<int> a(1, 0);
    for (int i = 0; i < N; ++i) {
      if (bit & 1 << i)
        a.push_back(d[i]);
      else
        a.push_back((24 - d[i]) % 24);
    }
    chmax(ans, mindiff(a));
  }
  cout << ans << endl;
}
