#include <bits/stdc++.h>
using namespace std;
int a[100], tot, cnt[100], b[100], ans, n, x;
void dfs(int x) {
  if (x > tot) {
    int num = 1e9;
    for (int i = 1; i <= n + tot; i++)
      for (int j = i + 1; j <= n + tot; j++) num = min(num, abs(b[i] - b[j]));
    ans = max(ans, num);
    return;
  }
  b[x + n] = a[x];
  dfs(x + 1);
  b[x + n] = 24 - a[x];
  dfs(x + 1);
}
int main() {
  scanf("%d", &n);
  cnt[0]++;
  while (n--) scanf("%d", &x), cnt[x]++;
  n = 0;
  for (int i = 0; i <= 12; i++)
    if (cnt[i] > 2) {
      puts("0");
      return 0;
    } else if (cnt[i] == 2) {
      if (!i) {
        puts("0");
        return 0;
      } else
        b[++n] = i, b[++n] = 24 - i;
    } else if (cnt[i] == 1)
      a[++tot] = i;
  dfs(1);
  printf("%d\n", ans);
}
