#include <bits/stdc++.h>
int N, D[50], b[50];
int cnt[13];
int used;
int main() {
  scanf("%d", &N);
  for (int i = (0); i < (N); ++i)
    scanf("%d", D + i), ++cnt[D[i]], used |= 1 << D[i];
  if (cnt[0] >= 1 || cnt[12] >= 2) {
    puts("0");
    return 0;
  }
  for (int i = (0); i < (13); ++i)
    if (cnt[i] >= 3) {
      puts("0");
      return 0;
    }
  if (N < 14) {
    int ans = 0;
    D[N] = 0;
    for (int i = 0; i <= (1 << 14); ++i) {
      int mi = 1 << 30;
      for (int j = (0); j < (N + 1); ++j)
        b[j] = D[j] + (i >> j & 1 ? 24 - 2 * D[j] : 0);
      for (int j = (0); j < (N + 1); ++j)
        for (int k = (0); k < (N + 1); ++k)
          if (j != k)
            mi =
                std::min(mi, std::min(abs(b[k] - b[j]), 24 - abs(b[k] - b[j])));
      ans = std::max(ans, mi);
    }
    if (N == 1) ans = std::min(D[0], 24 - D[0]);
    printf("%d\n", ans);
  }
  return 0;
}
