#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
void cout_vec(vector<int> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    if (i != 0) {
      cout << ' ';
    }
    cout << vec[i];
  }
  cout << endl;
}
vector<int> D(13, 0);
int search(vector<int> &vec, int n) {
  if (n == 13) {
    int ret = 12;
    sort(vec.begin(), vec.end());
    int a = vec.size();
    for (int i = 0; i < a; i++) {
      ret = min(ret, abs(vec[(i + 1) % a] - vec[i]));
      ret = min(ret, abs(24 - (vec[(i + 1) % a] - vec[i])));
    }
    return ret;
  }
  if (D[n] == 1) {
    vec.push_back(n);
    int b = search(vec, n + 1);
    vec.pop_back();
    vec.push_back(24 - n);
    int c = search(vec, n + 1);
    vec.pop_back();
    return max(b, c);
  }
  return search(vec, n + 1);
}
int main() {
  int N;
  cin >> N;
  vector<int> clock(1, 0);
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    D[d]++;
    if (D[d] >= 3) {
      cout << 0 << endl;
      return 0;
    } else if (D[d] == 2) {
      clock.push_back(d);
      clock.push_back(24 - d);
    }
  }
  int ans = search(clock, 0);
  cout << ans << endl;
}
