#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF = 200000000000000;
const double inf = pow(10, 10);
double pi = 3.141592653589793;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000007;
void init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed;
}
int main() {
  init();
  long long N;
  cin >> N;
  vector<long long> D(N);
  for (int i = 0; i < N; i++) cin >> D[i];
  D.push_back(0);
  sort(D.begin(), D.end());
  vector<long long> num(25, 0);
  for (int i = 0; i <= N; i++) {
    if (num[D[i]] >= 1 && num[24 - D[i]] == 0) {
      D[i] = (24 - D[i]) % 24;
    } else if (num[D[i]] == 0 && num[24 - D[i]] >= 1) {
    } else if (D[i] % 2 == 1) {
      D[i] = (24 - D[i]) % 24;
    }
    num[D[i]]++;
  }
  long long ans = INF;
  sort(D.begin(), D.end());
  for (int i = 1; i <= N; i++) {
    ans = min(ans, D[i] - D[i - 1]);
  }
  cout << ans << endl;
}
