#include <bits/stdc++.h>
using namespace std;
template <typename X>
bool exist(vector<X> vec, X item) {
  return find(vec.begin(), vec.end(), item) != vec.end();
}
long long N;
string cal(int i) {
  string ret = "";
  while (i != 0) {
    if (i % 2 == 1)
      ret.push_back('1');
    else
      ret.push_back('0');
    i /= 2;
  }
  while (ret.size() < N) {
    ret += '0';
  }
  return ret;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  vector<long long> D;
  for (long long i = (long long)0; i < (long long)N; i++) {
    long long inp;
    cin >> inp;
    D.push_back(inp);
  }
  long long num = 0;
  long long ans = 0;
  while (true) {
    string check = cal(num);
    if (check.size() > N) break;
    vector<long long> temp;
    long long tempmin = 24;
    for (long long i = (long long)0; i < (long long)N; i++) {
      if (check[i] == '1')
        temp.push_back(D[i]);
      else {
        if (D[i] == 0)
          temp.push_back(0);
        else
          temp.push_back(24 - D[i]);
      }
    }
    for (long long i = (long long)0; i < (long long)N; i++) {
      for (long long j = (long long)0; j < (long long)N; j++) {
        if (i == j)
          continue;
        else
          tempmin = min(abs(temp[i] - temp[j]), tempmin);
      }
      tempmin = min(tempmin, temp[i]);
    }
    ans = max(ans, tempmin);
    num++;
  }
  cout << ans << endl;
  return 0;
}
