#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#define ROP(i,n) for(int i=0;i<n;i++)
using namespace std;
priority_queue<int> que;
int main(){
  int N,D[50],DD[50];
  scanf("%d",&N);
  if(N==1) printf("0\n"),return 0;
  ROP(i,N){
    scanf(" %d",&D[i]);
    DD[i]=D[i];
    if(D[i]==0){
      printf("0\n");
      return 0;
    }
  }
  ROP(i,N){
    int MIN=12;DD[i]=24-D[i];
    ROP(j,N){
      if(i==j) continue;
      MIN=min(MIN,abs(DD[i]-D[j]));
    }
    DD[i]=D[i];
    ROP(j,N){
      if(i==j) continue;
      if(DD[i]==D[j]) continue;
      MIN=min(MIN,abs(DD[i]-D[j]));
    }
    ROP(i,N){
      MIN=min(MIN,D[i]);
    }
    que.push(MIN);
  }
  printf("%d\n",que.top());
  return 0;
}
