#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int INF = INT_MAX / 2;
int D[13];
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < (N); i++) {
    int x;
    cin >> x;
    D[x]++;
    if (D[x] > 2) {
      cout << 0 << endl;
      return 0;
    }
  }
  if (N == 1) {
    cout << 0 << endl;
    return 0;
  }
  if (D[0] > 1 || D[12] > 1) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 0;
  for (int i = 0; i < ((1 << 11)); i++) {
    vector<int> x;
    if (D[0]) x.push_back(0);
    if (D[12]) x.push_back(12);
    for (int j = 0; j < (11); j++) {
      if (D[j + 1] == 2) {
        x.push_back(j + 1);
        x.push_back(24 - (j + 1));
      }
      if (D[j + 1] == 1) {
        if ((i >> j) & 1)
          x.push_back(j + 1);
        else
          x.push_back(24 - (j + 1));
      }
    }
    int tmp = INF;
    for (int j = 0; j < N - 1; j++) {
      for (int k = j + 1; k < N; k++) {
        tmp = min(tmp, abs(x[j] - x[k]));
      }
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
