#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
struct unit {
  int index;
  int num;
} save[maxn];
bool compare(unit a, unit b) { return a.num < b.num; }
int naka[maxn];
int main() {
  int n, i, j;
  while (~scanf("%d", &n)) {
    for (i = 1; i <= n; i++) {
      scanf("%d", &save[i].num);
      save[i].index = i;
    }
    save[n + 1].num = 0;
    save[n + 1].index = n + 1;
    ++n;
    sort(save + 1, save + 1 + n, compare);
    for (i = 1; i < n; i++) {
      naka[i] = save[i + 1].num - save[i].num;
    }
    naka[0] = 0;
    int res = -1;
    int p = 1;
    while (save[p].num == 0 && save[p].index <= n) {
      ++p;
    }
    for (i = p; i <= n; i++) {
      int nowMin = 0x3f3f3f3f;
      for (j = p; j < n; j++) {
        if (j == i) {
          nowMin = min(naka[i - 1] + naka[i], nowMin);
        } else {
          nowMin = min(naka[i], nowMin);
        }
      }
      if (save[i].num != 0) {
        nowMin = min((24 - save[i].num) - save[n].num, nowMin);
        res = max(res, nowMin);
      }
    }
    if (res == -1) {
      printf("0\n");
    } else {
      printf("%d\n", res);
    }
  }
  return 0;
}
