#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
const int M = 205;
const int INF = 0x3f3f3f3f;
const double inf = 2e9;
const double Pi = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-8;
int n, m;
int s[N];
int vis[N];
bool sat(int x) {
  memset(vis, 0, sizeof vis);
  int pre = 0;
  vis[0]++;
  for (int i = 1; i <= n; i++) {
    int a = s[i];
    if (a - pre < x)
      vis[24 - a]++;
    else {
      vis[a]++;
      pre = a;
    }
  }
  int f = 0;
  for (int i = 0; i <= 24; i++) {
    if (vis[i] == 1) {
      for (int j = 1; j <= x; j++) {
        int a = (i + j) % 24;
        int b = (i - j + 24) % 24;
        if (vis[a] || vis[b]) return false;
      }
    } else if (vis[i] > 1)
      return false;
  }
  return true;
}
int main() {
  while (~scanf("%d", &n)) {
    s[0] = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
    sort(s, s + n + 1);
    if (s[1] == 0) {
      printf("0\n");
      continue;
    }
    int l = 0, r = 12;
    int ans = 0, mid;
    while (l < r) {
      mid = (l + r) >> 1;
      if (sat(mid)) {
        ans = mid;
        l = mid + 1;
      } else
        r = mid;
    }
    printf("%d\n", ans + 1);
  }
  return 0;
}
