#include <bits/stdc++.h>
using namespace std;
const int INF = 1 << 30;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> D(N), cnt(13, 0);
  for (int i = (int)0; i < (int)N; ++i) {
    cin >> D[i];
    cnt[D[i]]++;
  }
  for (int i = (int)0; i < (int)13; ++i) {
    if ((i == 0 || i == 12) && cnt[i] >= 2) {
      cout << 0 << endl;
      return 0;
    }
    if (cnt[i] >= 3) {
      cout << 0 << endl;
      return 0;
    }
  }
  int ans = 0;
  for (int mask = (int)0; mask < (int)1 << 11; ++mask) {
    vector<bool> is_exist(24, false);
    is_exist[0] = true;
    for (int i = (int)0; i < (int)13; ++i) {
      if (cnt[i + 1] == 0)
        continue;
      else if (cnt[i + 1] == 1) {
        if (mask & (1 << i))
          is_exist[i + 1] = true;
        else
          is_exist[23 - i] = true;
      } else {
        is_exist[i + 1] = is_exist[23 - i] = true;
      }
    }
    int now_ans = INF;
    for (int i = (int)0; i < (int)24; ++i)
      for (int j = (int)i + 1; j < (int)24; ++j) {
        if (is_exist[i] && is_exist[j]) {
          now_ans = min(now_ans, min(abs(i - j), 24 - abs(i - j)));
        }
      }
    if (now_ans == INF) continue;
    ans = max(ans, now_ans);
  }
  cout << ans << endl;
  return 0;
}
