#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
vector<int> v(222);
priority_queue<PP> Q;
int N;
set<P> SET;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  N++;
  int D[N];
  D[0] = 0;
  FOR(i,1,N) cin >> D[i];
  FOR(i,0,N) {
    v[i] = D[i];
    v[i+N] = 24-D[i];
  }
  FOR(i,0,2*N) {
    FOR(j,i+1,2*N) {
      if(j == i + N) continue;
      Q.push(PP(min(24-abs(v[i]-v[j]), abs(v[i]-v[j])), P(i, j)));
    }
  }

  int cnt = 0;
  while(!Q.empty()) {
    PP pp = Q.top(); Q.pop();
    int d = pp.first;
    int u = pp.second.first;
    int v = pp.second.second;
    if(!SET.count(P(min(u, v), max(u, v)))) {
      bool plus = false;
      int uu = u < N ? u + N : u - N;
      int vv = v < N ? v + N : v - N;
      if(SET.count(P(min(uu, v), max(uu, v))) || SET.count(P(min(u, vv), max(u, vv))) || SET.count(P(min(uu, vv), max(uu, vv)))) plus = false;
      else plus = true;
      SET.insert(P(min(u, v), max(u, v)));
      cnt += plus;
      if(cnt == N * (N - 1) / 2){
        cout << d << endl;
        return 0;
      }
    }
  }
}