#include <bits/stdc++.h>
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const long long LL_INF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;
int c[13];
int cl[25];
int ans;
void dfs(int i) {
  if (i == 13) {
    int res = 24;
    int tmp = 1;
    for (int j = 1; j <= 24; j++) {
      if (cl[j] > 0) {
        res = min(res, tmp);
        tmp = 1;
      } else {
        tmp++;
      }
    }
    ans = max(res, ans);
    return;
  }
  if (c[i] == 0) {
    dfs(i + 1);
  } else if (c[i] == 1) {
    cl[i]++;
    dfs(i + 1);
    cl[i]--;
    if (i != 12) {
      cl[24 - i]++;
      dfs(i + 1);
      cl[24 - i]--;
    }
  } else if (c[i] == 2) {
    cl[c[i]]++;
    cl[24 - i]++;
    dfs(i + 1);
  } else {
    cout << "ERROR" << endl;
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int d[105];
  c[0]++;
  for (int i = 0; i < N; i++) {
    cin >> d[i];
    c[d[i]]++;
  }
  bool zero = false;
  for (int i = 0; i < (13); i++) {
    if (i == 12 or i == 0) {
      if (c[i] >= 2) zero = true;
    } else if (c[i] >= 3) {
      zero = true;
    }
  }
  if (zero) {
    cout << 0 << endl;
  } else {
    cl[0] = cl[24] = 1;
    ans = 0;
    dfs(1);
    cout << ans << endl;
  }
  return 0;
}
