#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
const int inf = 0x3f3f3f3f;
int save[maxn];
int ji[maxn], ou[maxn];
int myClock[maxn];
int res;
void dfs(int index) {
  if (index > 12) {
    return;
  }
  int i;
  int sum = 1;
  int nowMin = inf;
  for (i = 0; i < 24; i++) {
    if (myClock[i] == 1 && i != 0) {
      nowMin = min(sum, nowMin);
      sum = 1;
    } else if (myClock[i] == 0) {
      ++sum;
    } else if (myClock[i] > 1) {
      nowMin = 0;
      sum = 1;
    }
  }
  nowMin = min(sum, nowMin);
  res = max(res, nowMin);
  if (myClock[index] == 1) {
    dfs(index + 1);
    ++myClock[24 - index];
    --myClock[index];
    dfs(index + 1);
  } else if (myClock[index] == 2) {
    ++myClock[24 - index];
    --myClock[index];
    dfs(index + 1);
  } else if (myClock[index] > 2) {
    res = max(res, 0);
  } else {
    dfs(index + 1);
  }
}
int main() {
  int n, i, j, k;
  while (~scanf("%d", &n)) {
    memset(myClock, 0, sizeof(myClock));
    for (i = 1; i <= n; i++) {
      scanf("%d", &save[i]);
      ++myClock[save[i]];
    }
    myClock[0] += 1;
    res = 0;
    dfs(1);
    printf("%d\n", res);
  }
  return 0;
}
