#include <algorithm>
#include <iostream>
using namespace std;
int N;
int dp[37][(1<<24)];

int main(){

  cin >> N;
  int D[N];
  for(int i = 0; i < N; ++i) cin >> D[i];
  sort(D,D+N);
  if(N > 36){
    cout << "0" << endl;
    return 0;
  }
  dp[0][1] = 24;
  for(int i = 0; i < N; ++i){
    for(int j = 1; j < (1<<24); ++j){
      if(dp[i][j] == 0) continue;
      int t1 = (1<<(D[i])), t2 = (1<<((24-D[i])%24));
      if((j & t1) == 0){
        int d = dp[i][j];
        for(int k = 0; k < 24; ++k){
          if((j>>k) & 1) d = min(d,abs(D[i]-k));
        }
        dp[i+1][j|t1] = max(dp[i+1][j|t1],d);
      }
      if((j & t2) == 0){
        int d = dp[i][j];
        for(int k = 0; k < 24; ++k){
          if((j>>k) & 1) d = min(d,abs((24-D[i])%24-k));
        }
        dp[i+1][j|t2] = max(dp[i+1][j|t2],d);
      }
    }
  }

  int ans = 0;
  for(int i = 0; i < (1<<24); ++i){
    ans = max(ans,dp[N][i]);
  }
  cout << ans << endl;
  return 0;
}
