#include <bits/stdc++.h>
int comp(const void* a, const void* b) { return *(int*)a - *(int*)b; }
int d[50];
int cur[2], next[2];
int f1[2], f2[2];
int n;
int check(int s) {
  int cnt, diff, f, i, j, k;
  f1[0] = f1[1] = f2[0] = f2[1] = 0;
  cur[0] = cur[1] = 0;
  for (i = (0); i < (n); i++) {
    next[0] = d[i], next[1] = (24 - d[i]) % 24;
    for (j = (0); j < (2); j++) {
      cnt = f = 0;
      for (k = (0); k < (2); k++) {
        if (f1[k]) continue;
        diff = abs(next[j] - cur[k]);
        ;
        if (diff >= s) cnt++;
      }
      if (cnt > 0)
        f = 1;
      else
        f2[j] = 1;
    }
    if (!f) return 0;
    f1[0] = f2[0], f1[1] = f2[1];
    cur[0] = next[0], cur[1] = next[1];
  }
  return 1;
}
int main(void) {
  int left, right, mid, i;
  scanf("%d", &n);
  for (i = (0); i < (n); i++) scanf("%d", d + i);
  ;
  left = 0, right = 24;
  while (right - left > 1) {
    mid = (left + right) / 2;
    if (check(mid))
      left = mid;
    else
      right = mid;
  }
  printf("%d\n", left);
  return 0;
}
