#include <bits/stdc++.h>
int solve(int N, std::vector<int> D) {
  if (N > 24 || N == 1) {
    return 0;
  }
  std::vector<int> cnt(13);
  for (int i = 0; i < N; i++) {
    cnt[D[i]]++;
    if (cnt[D[i]] == 3) {
      return 0;
    }
  }
  if (N > 12) {
    return 1;
  }
  int ret = 0;
  for (int i = 0; i < (1 << N); i++) {
    std::vector<int> d(N);
    for (int j = 0; j < N; j++) {
      if (i >> j & 1) {
        d[j] = D[j];
      } else {
        d[j] = 24 - D[j];
      }
    }
    std::sort(d.begin(), d.end());
    int score = 114514;
    for (int j = 0; j <= N; j++) {
      int diff = std::min(d[(j + 1) % N] - d[j], 24 - (d[(j + 1) % N] - d[j]));
      score = std::min(score, diff);
    }
    ret = std::max(ret, score);
  }
  return ret;
}
int main() {
  int N;
  std::cin >> N;
  std::vector<int> D(N);
  for (int i = 0; i < N; i++) {
    std::cin >> D[i];
  }
  std::cout << solve(N, D) << std::endl;
  return 0;
}
