#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,a) for(int i=0;i<(a);i++)
#define MOD 1000000007

const int INF=INT_MAX/2;
int D[13];

int main(){
  int N; cin>>N;
  D[0]=2;
  rep(i,N){
    int x; cin>>x;
    D[x]++;
    if(D[x]>2){
      cout<<0<<endl;
      return 0;
    }
  }
  if(D[12]>1){
    cout<<0<<endl;
    return 0;
  }
  int ans=0;
  rep(i,(1<<12)){
    vector<int> x;
    if(D[12]) x.push_back(12);
    rep(j,12){
      if(D[j]==2){
        x.push_back(j);
        x.push_back(24-j);
      }
      if(D[j]==1){
        if((i>>j)&1) x.push_back(j);
        else x.push_back(24-j);
      }
    }
    sort(x.begin(),x.end());
    int tmp=24,sz=x.size();
    rep(j,sz-1){
      tmp=min(tmp,x[j+1]-x[j]);
    }
    ans=max(ans,tmp);
  }
  cout<<ans<<endl;
  return 0;
}
