#include <bits/stdc++.h>
using namespace std;
int n, a[57], cnt[57], b[57], now = 0;
void dfs(int pos) {
  if (pos > n) {
    for (int i = 1; i <= n; i++) b[i] = a[i];
    sort(b + 1, b + n + 1);
    int res = 30;
    for (int i = 1; i < n; i++) res = min(res, b[i + 1] - b[i]);
    now = max(now, res);
  } else {
    if (a[pos] != 0 && a[pos] != 12) {
      a[pos] = 24 - a[pos];
      dfs(pos + 1);
      a[pos] = 24 - a[pos];
    }
    dfs(pos + 1);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  memset(cnt, 0, sizeof(cnt));
  ++cnt[0];
  for (int i = 1; i <= n; i++) ++cnt[a[i]];
  ++n;
  a[n] = 0;
  for (int i = 0; i <= 12; i++) {
    if ((i == 0 || i == 12) && cnt[i] > 1) {
      cout << 0 << endl;
      return 0;
    } else if (cnt[i] > 2) {
      cout << 0 << endl;
      return 0;
    }
  }
  dfs(1);
  printf("%d\n", now);
  return 0;
}
