#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  bool flag = false;
  scanf("%d", &N);
  vector<int> D(N + 1);
  D[0] = 0;
  for (int i = 0; i < (N); ++i) scanf("%d", &D[i + 1]);
  sort(begin(D), end(D));
  if (D[1] == 0) flag = true;
  if (D[N] == 12 and D[N - 1] == 12) flag = true;
  for (int i = 0; i < (N - 1); ++i) {
    if (D[i] == D[i + 1] and D[i + 1] == D[i + 2]) flag = true;
  }
  int inv = 0;
  int ans = -1;
  int tmp;
  if (flag)
    printf("0");
  else if (N >= 12)
    printf("1");
  else {
    while (inv < pow(2, N)) {
      for (int i = 0; i < (N); ++i) {
        if ((inv >> i) % 2 == 1) {
          if (D[i + 1] > 0) D[i + 1] = 24 - D[i + 1];
        }
      }
      tmp = 12;
      for (int i = 0; i < (N + 1); ++i) {
        for (int j = (i + 1); j < (N + 1); ++j) {
          tmp = min(tmp, min(abs(D[i] - D[j]), 24 - abs(D[i] - D[j])));
        }
      }
      ans = max(ans, tmp);
      inv += 1;
    }
    printf("%d", ans);
  }
  return 0;
}
