#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long t = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') t = t * 10 + c - '0', c = getchar();
  return t * f;
}
inline void write(long long x) {
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writeln(long long x) {
  write(x);
  puts("");
}
inline void write_p(long long x) {
  write(x);
  putchar(' ');
}
int ans, rev[101], cnt[101], n, d[101], t[101], tim;
inline void check() {
  for (long long i = 1; i <= n; ++i)
    if (rev[i])
      t[i] = d[i];
    else
      t[i] = 24 - d[i];
  int tans = 1e8;
  for (long long i = 1; i <= n; ++i)
    for (long long j = i + 1; j <= n; ++j)
      tans = min(tans, min(24 - abs(t[i] - t[j]), abs(t[i] - t[j])));
  ans = max(tans, ans);
  tim++;
  if (tim * n * n > 3000000) {
    writeln(ans);
    exit(0);
  }
}
inline void dfs(int x) {
  if (x == n + 1) {
    check();
    return;
  }
  int t = rand() & 1;
  if (t == 1) {
    rev[x] = 0;
    dfs(x + 1);
    rev[x] = 1;
    dfs(x + 1);
    rev[x] = 0;
  } else {
    rev[x] = 1;
    dfs(x + 1);
    rev[x] = 0;
    dfs(x + 1);
    rev[x] = 0;
  }
}
int main() {
  srand(time(0));
  n = read();
  for (long long i = 1; i <= n; ++i) d[i] = read(), cnt[d[i]]++;
  d[n + 1] = 0;
  n++;
  cnt[0]++;
  sort(d + 1, d + n + 1);
  if (n >= 25) {
    puts("0");
    return 0;
  }
  for (long long i = 0; i <= 12; ++i)
    if (cnt[i] > 3) {
      puts("0");
      return 0;
    }
  dfs(1);
  writeln(ans);
}
