#include <iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<random>
using namespace std;

int main() {

  int n; cin >> n;
  vector<int> d(n);
  for(int i=0; i<n; i++) cin >> d[i];
  sort(d.begin(), d.end());

  vector<int> a(24, 0);
  a[0]++;
  for(int i=0; i<n; i++){
    if( i % 2 == 0 ) a[ d[i]%24 ]++;
    else a[ (24-d[i])%24 ]++;
  }

  int mn = 1e9;
  for(int i=0; i<24; i++){
    if( a[i] > 1 ){
      cout << 0 << endl;
      return 0;
    }
    if( a[i] == 0 ) continue;
    for(int j=i+1; j<24; j++){
      if( a[j] == 0 ) continue;
      mn = min(mn, (j-i));
    }
  }
  cout << (mn==24 ? 0 : mn) << endl;

  return 0;
}

// EOF
