#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 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;
    bool change;
    int res = -1;
    change = true;
    for (j = 1; j < 12; j++) {
      if (myClock[j] != 0) {
        if (change) {
          --myClock[j];
          ++myClock[24 - j];
        }
        change = !change;
      }
    }
    int nowMin = inf;
    int sum = 1;
    for (j = 0; j < 24; j++) {
      if (myClock[j] == 1 && j != 0) {
        nowMin = min(sum, nowMin);
        sum = 1;
      } else if (myClock[j] == 0) {
        ++sum;
      } else if (myClock[j] > 1) {
        nowMin = 0;
      }
    }
    nowMin = min(sum, nowMin);
    res = max(res, nowMin);
    printf("%d\n", res);
  }
  return 0;
}
