#include <bits/stdc++.h>
using namespace std;
int n, d[2333], sd[2333], ca = 0;
int f[233];
inline void dfs(int x) {
  if (x > n) {
    for (int i = 0; i <= 24; ++i) f[i] = 0;
    for (int i = 0; i <= n; ++i) {
      if (f[d[i]]) return;
      f[d[i]] = 1;
    }
    int g = 0;
    for (int i = 0; i <= 24; ++i)
      if (f[i]) sd[g++] = i;
    int ans = 1e9;
    for (int i = 1; i <= n && ans > ca; ++i) {
      int g = sd[i] - sd[i - 1];
      if (g > 24 - g) g = 24 - g;
      if (g < ans) ans = g;
    }
    if (ca < ans) ca = ans;
    return;
  }
  dfs(x + 1);
  x[d] = 24 - x[d];
  dfs(x + 1);
  x[d] = 24 - x[d];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", d + i);
  if (n >= 25) {
    puts("0");
    return 0;
  }
  dfs(1);
  printf("%d\n", ca);
}
