#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define clr(a,v) memset((a),(v),sizeof(a))

int N, D[55], b[55];
int cnt[55];

int main()
{
  scanf( "%d", &N );
  rep( i, N )
    scanf( "%d", D+i ), ++cnt[D[i]];

  int ans = 1;

  if( N >= 14 )
  {
    if( cnt[0] >= 1 || cnt[12] >= 2 )
      ans = 0;

    repi( i, 1, 12 ) if( cnt[i] >= 3 )
      ans = 0;
  }
  else
  {
    ans = 0;
    D[N] = 0;
    for( int i = 0; i <= (1<<14); ++i )
    {
      int mi = 1<<30;
      rep( j, N+1 )
        b[j] = D[j]+(i>>j&1?24-2*D[j]:0);

      rep( j, N+1 ) rep( k, N+1 ) if( j != k )
        mi = std::min( mi, std::min( abs(b[k]-b[j]), 24-abs(b[k]-b[j]) ) );

      ans = std::max( ans, mi );
    }
  }

  if( N == 1 )
    ans = std::min( D[0], 24-D[0] );

  printf( "%d\n", ans );

  return 0;
}