#include <bits/stdc++.h>
int main() {
  int N;
  scanf("%d", &N);
  if (N > 22) return !printf("0\n");
  std::vector<int> D(N);
  for (int i = 0; i < N; ++i) scanf("%d", &D[i]);
  D.push_back(!++N);
  auto f = [](int d, int bits, int i) -> int {
    return (bits >> i & 1) ? d : 24 - d;
  };
  int res = 0;
  for (int bits = 0; bits < (1 << N); ++bits) {
    int cur = 24;
    for (int i = 0; i < N; ++i) {
      for (int j = i + 1; j < N; ++j) {
        int a = f(D[i], bits, i);
        int b = f(D[j], bits, j);
        int d = std::abs(a - b);
        cur = std::min(cur, std::min(d, 24 - d));
      }
    }
    res = std::max(res, cur);
  }
  printf("%d\n", res);
  return 0;
}
