#include <bits/stdc++.h>
using namespace std;
int a[13];
int m;
int ans = 0;
int t[30];
int c[30];
int d[30];
int cnt = 0;
inline void dfs(int q) {
  if (q > m) {
    int xx = 1 << 30;
    for (int i = 1; i <= cnt; i++) {
      xx = min(c[i] - c[i - 1], xx);
      if (c[i] > 12)
        if (a[24 - c[i]] > 1 && !d[24 - c[i]]) xx = 0;
      if (c[i] <= 12)
        if (a[c[i]] > 1 && !d[24 - c[i]]) xx = 0;
    }
    xx = min(c[cnt] - c[1], xx);
    xx = min(24 - c[1], xx);
    xx = min(24 - c[cnt], xx);
    if (xx != 1 << 30) ans = max(xx, ans);
    return;
  }
  int x = t[q];
  if (x >= 12) {
    if (a[24 - x] == 1 && d[24 - x])
      dfs(q + 1);
    else {
      c[++cnt] = x;
      d[x] = 1;
      dfs(q + 1);
      d[x] = 0;
      cnt--;
      if (d[24 - x] == 0) return;
      if (x != 12 && a[24 - x] != 1 && d[24 - x] != 0) {
        dfs(q + 1);
      }
    }
  } else {
    c[++cnt] = x;
    d[x] = 1;
    dfs(q + 1);
    d[x] = 0;
    cnt--;
    dfs(q + 1);
  }
}
int main() {
  int n;
  cin >> n;
  int x;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    a[x]++;
    if (a[x] >= 3) {
      puts("0");
      return 0;
    }
  }
  if (a[0]) {
    puts("0");
    return 0;
  }
  m = 0;
  for (int i = 1; i <= 12; i++)
    if (a[i]) {
      t[++m] = i;
      if (i != 12) t[++m] = 24 - i;
    }
  sort(t + 1, t + 1 + m);
  dfs(1);
  cout << ans << endl;
}
