#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 1047483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int ma=0;
int time[13]={};
int n;
int mm=0;
void dfs(int depth,int s){
  if(depth==13||depth==mm+1){
    if(s!=INF)
      ma=max(s,ma);
    // cout<<ma<<endl;
    return;
  }
  int s2=s;
  for(int i=1;i<depth;i++){
    if(time[i]>0){
      //cout<<"!"<<endl;
      s=min(s,abs(depth-i));
      s2=min(s2,abs((24-depth)-i));
    }
  }
  if(time[depth]>=2){
    s=min(s,0);
    s2=min(s2,24-2*depth);
  }
  dfs(depth+1,s);
  dfs(depth+1,s2);
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    time[a]++;
  }
  for(int i=12;i>=1;i--)
    if(time[i]){
      mm=i;
      break;
    }
  dfs(1,INF);
  cout<<ma<<endl;
  return 0;
}
