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