#include <iostream>
#include <vector>
using namespace std;
int solve(int s, int N, vector<int> &D, vector<int> t, int d){
  if(s == N || d == 0) return d;
  int x = D[s], y = (24-D[s])%24, d1 = d, d2 = d;
  for(int i = 0; i <= s; ++i){
    d1 = min(d1,min(abs(t[i]-x),24-abs(t[i]-x)));
    d2 = min(d2,min(abs(t[i]-y),24-abs(t[i]-y)));
  }
  vector<int> t1 = t, t2 = t;
  t1.push_back(x);
  t2.push_back(y);
  return max(solve(s+1,N,D,t1,d1), solve(s+1,N,D,t2,d2));
}

int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  for(int i = 0; i < N; ++i) cin >> D[i];
  if(N > 35){
    cout << "0" << endl;
    return 0;
  }
  vector<int> init(1,0);
  cout << solve(0,N,D,init,24) << endl;
  return 0;
}
