#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;

int main() {
  int N; cin >> N;
  int D[N+1]; CLR(D);
  FOR(i,1,N+1) cin >> D[i];
  sort(D, D + N + 1);
  FOR(i,0,N+1) if(i%2) D[i] = 24 - D[i];
  int ans = 1e9;
  FOR(i,0,N+1) {
    int j = (i + 1) % (N+1);
    int k = (i + 2) % (N+1);
    ans = min(ans, min(abs(D[i]-D[j]), 24-abs(D[i]-D[j])));
    if(i != k) ans = min(ans, min(abs(D[i]-D[k]), 24-abs(D[i]-D[k])));
  }
  cout << ans << endl;
  return 0;
}