#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:1024000000,1024000000")
inline long long Scan() {
  long long x = 0;
  int f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 55;
int a[N];
vector<int> v;
int Sol(int x) {
  v.clear();
  v.push_back(0);
  for (register int i = 1; i <= 12; ++i) {
    if (x & (1 << i)) {
      if (a[i] == 0)
        return 0;
      else if (a[i] == 1)
        v.push_back(i);
      else
        v.push_back(i), v.push_back(24 - i);
    } else {
      if (a[i] == 1)
        v.push_back(24 - i);
      else if (a[i] > 1)
        return 0;
    }
  }
  sort(v.begin(), v.end());
  int ma = 100;
  for (int i = 1; i < v.size(); ++i) ma = min(ma, v[i] - v[i - 1]);
  return ma == 100 ? 0 : ma;
}
int main() {
  int n, x, ma = 0;
  scanf("%d", &n);
  for (register int i = 1; i <= n; ++i) scanf("%d", &x), ++a[x];
  for (register int i = 1; i <= 11; ++i) ma = max(ma, a[i]);
  if (a[0] || a[12] > 1 || ma > 2) {
    puts("0");
    return 0;
  }
  int top = (1 << 13) - 1;
  int ans = 0;
  for (register int i = 0; i <= top; ++i) {
    if (i & 1) continue;
    ans = max(ans, Sol(i));
  }
  printf("%d\n", ans);
  return 0;
}
