#include <bits/stdc++.h>
using namespace std;
int read() {
  char s;
  int k = 0, base = 1;
  while ((s = getchar()) != '-' && s != EOF && !(s >= '0' && s <= '9'))
    ;
  if (s == EOF) exit(0);
  if (s == '-') base = -1, s = getchar();
  while (s >= '0' && s <= '9') {
    k = k * 10 + (s - '0');
    s = getchar();
  }
  return k * base;
}
void write(int x) {
  if (x < 0) {
    putchar('-');
    write(-x);
  } else {
    if (x / 10) write(x / 10);
    putchar(x % 10 + '0');
  }
}
const int maxn = 110;
int n, ans, l, r;
int a[maxn];
int b[maxn], c[maxn];
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    c[i] = read();
  }
  l = 0;
  r = 24;
  if (n == 1) {
    printf("%d\n", c[1]);
    return 0;
  }
  while (l < r) {
    int mid = (l + r + 1) / 2, a1 = 0, a2 = 0;
    bool flag = true;
    memset(b, 0, sizeof(b));
    b[0] = 1;
    b[24] = 1;
    for (int i = 1; i <= n; i++) {
      bool qaq = false, qwq = true, bj1 = false, bj2 = false;
      a[i] = c[i];
      for (int j = max(0, a[i] - mid + 1); j <= min(24, a[i] + mid - 1); j++) {
        if (b[j] == 1) {
          qwq = false;
          break;
        }
      }
      if (qwq) {
        for (int j = a[i]; j >= 0; j--) {
          if (b[j] == 1) {
            a1 = a[i] - j;
            break;
          }
        }
        for (int j = a[i]; j <= 24; j++) {
          if (b[j] == 1) {
            a1 = min(a1, j - a[i]);
          }
        }
        qaq = true;
        bj1 = true;
      }
      qwq = true;
      a[i] = 24 - c[i];
      for (int j = max(0, a[i] - mid + 1); j <= min(24, a[i] + mid - 1); j++) {
        if (b[j] == 1) {
          qwq = false;
          break;
        }
      }
      if (qwq) {
        for (int j = a[i]; j >= 0; j--) {
          if (b[j] == 1) {
            a2 = a[i] - j;
            break;
          }
        }
        for (int j = a[i]; j <= 24; j++) {
          if (b[j] == 1) {
            a2 = min(a2, j - a[i]);
          }
        }
        qaq = true;
        bj2 = true;
      }
      if (!qaq) {
        flag = false;
        break;
      }
      if (bj1 && bj2) {
        if (a1 <= a2) {
          b[c[i]] = 1;
        } else {
          b[24 - c[i]] = 1;
        }
      } else {
        if (bj1)
          b[c[i]] = 1;
        else
          b[24 - c[i]] = 1;
      }
    }
    if (!flag)
      r = mid - 1;
    else
      l = mid;
  }
  printf("%d\n", l);
  return 0;
}
