void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.math;

  int n; rd(n);
  auto d=readln.split.to!(int[]);

  int[int] h;
  foreach(e; d){
    if((e in h)==null) h[e]=0;
    if(++h[e]>2){writeln(0); return;}
  }

  if(0 in h){writeln(0); return;}

  int mx=0;
  auto v=new int[](0); v~=0;
  foreach(k; h.keys){
    foreach(_; 0..h[k]) v~=k;
  }
  auto m=v.length;
  for(int bit=0; bit<(1<<m); bit++){
    auto u=new int[](m);
    foreach(i; 0..m){
      if(bit&(1<<i)) u[i]=v[i];
      else u[i]=(24-v[i]);
    }
    int mn=1000;
    sort(u);
    foreach(i; 1..m) mn=min(mn, u[i]-u[i-1]);
    mx=max(mx, mn);
  }

  writeln(mx);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
