#include <bits/stdc++.h>
using namespace std;
int N;
int D[60];
int main() {
  cin >> N;
  for (auto i = 0; i < N; ++i) {
    cin >> D[i];
  }
  int cnt[13];
  fill(cnt, cnt + 13, 0);
  cnt[0] = 1;
  for (auto i = 0; i < N; ++i) {
    cnt[D[i]]++;
  }
  if (cnt[0] >= 2 || cnt[12] >= 2) {
    cout << 0 << endl;
    return 0;
  }
  for (auto i = 1; i <= 11; ++i) {
    if (cnt[i] >= 3) {
      cout << 0 << endl;
      return 0;
    }
  }
  int res = 0;
  for (auto x = 0; x < (1 << 13); ++x) {
    set<int> S;
    for (auto i = 0; i <= 12; ++i) {
      if (cnt[i] >= 2) {
        S.insert(i);
        S.insert((24 - i) % 24);
      } else if (cnt[i] == 1) {
        if (((x >> i) & 1) == 1) {
          S.insert(i);
        } else {
          S.insert((24 - i) % 24);
        }
      }
    }
    int ans = 100;
    for (auto e : S) {
      for (auto f : S) {
        if (e != f) {
          ans = min(ans, abs(e - f));
        }
      }
    }
    res = max(res, ans);
  }
  cout << res << endl;
}
