#include <cstdio>
#include <vector>
#include <cstdlib>
#include <algorithm>

int main() {
  int N;
  scanf("%d", &N);

  if (N > 23)
    return !printf("0\n");

  std::vector<int> D(N);
  for (int i=0; i<N; ++i) {
    scanf("%d", &D[i]);
  }

  D.push_back(!++N);

  int A[13]={};
  for (int i=0; i<N; ++i)
    if (++A[std::min(D[i], 24-D[i])] > 2)
      return !printf("0\n");

  if (N == 24)
    return !printf("1\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;
}
