#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF INT_MAX/3

int n;
int d[55];
vector<P> a;
bool used[101];

bool ok(int x){
  int i=0;
  int crth=0;
  int cnt=1;
  memset(used,0,sizeof(used));
  used[0]=true;
  while(1){
    while(i<a.size()&&(a[i].fi-crth<x||used[a[i].se]))i++;
    if(i==a.size())return false;
    used[a[i].se]=true;
    cnt++;
    if(cnt==n+1){
      if(min(a[i].fi,24-a[i].fi)>=x)return true;
      else return false;
    }
    crth=a[i].fi;
  }
  return false;
}

int main(){
	cin>>n;
  rep(i,n){
    cin>>d[i];
    if(d[i]==0||d[i]==12){
      a.push_back(P(d[i],i+1));
    }else{
      a.push_back(P(d[i],i+1));
      a.push_back(P(24-d[i],i+1));
    }
  }
  a.push_back(P(0,0));
  sort(all(a));
  rep(x,51){
    if(!ok(x)){
      cout<<x-1<<endl;
      return 0;
    }
  }
	return 0;
}
