#include <bits/stdc++.h>
using namespace std;
int n;
int c[25];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  int t;
  for (int i = 0; i < n; ++i) {
    cin >> t;
    c[t]++;
  }
  for (int j = 0; j <= 12; ++j) {
    if (c[j] >= 3) {
      cout << 0;
      return 0;
    }
  }
  int sol = -1e9;
  for (int i = 0; i < 1 << 13; ++i) {
    vector<int> a;
    for (int j = 0; j <= 12; ++j) {
      if (c[j] == 2) {
        a.push_back(j);
        a.push_back((24 - j) % 24);
      } else if (c[j] == 1) {
        if ((1 << j) & i)
          a.push_back((24 - j) % 24);
        else
          a.push_back(j);
      }
    }
    a.push_back(0);
    int n = ((int)(a).size());
    int minD = 1e9;
    for (int j = 0; j < n; ++j) {
      for (int k = j + 1; k < n; ++k) {
        minD = min(minD, abs(a[j] - a[k]));
      }
    }
    if (minD != 1e9) sol = max(sol, minD);
  }
  cout << sol;
  return 0;
}
