#include <bits/stdc++.h>
int min(int a, int b) { return (a > b) ? b : a; }
int max(int a, int b) { return (a > b) ? a : b; }
int mini(int a[], int K) {
  int m = a[0];
  for (int i = 0; i < K; i++) {
    if (a[i] < m) m = a[i];
  }
  return m;
}
int timeGap(int a, int b) {
  if (a < b)
    return min(b - a, 24 - b + a);
  else
    return min(a - b, 24 - a + b);
}
int main(void) {
  int N;
  int D[50];
  int rT[50][2];
  int d1[1225], d2[1225], d3[1225], d4[1225];
  int re;
  scanf("%d", &N);
  if (N == 1) {
    scanf("%d", &D[0]);
    printf("0\n");
  } else {
    for (int i = 0; i < N; i++) {
      scanf("%d", &D[i]);
    }
    for (int i = 0; i < N; i++) {
      rT[i][0] = D[i];
      rT[i][1] = 24 - D[i];
    }
    int id1 = 0, id2 = 0, id3 = 0, id4 = 0;
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (i != j) {
          d1[id1++] = timeGap(rT[i][0], rT[j][0]);
          d2[id2++] = timeGap(rT[i][0], rT[j][1]);
          d3[id3++] = timeGap(rT[i][1], rT[j][0]);
          d4[id4++] = timeGap(rT[i][1], rT[j][1]);
        }
      }
    }
    int m1, m2, m3, m4;
    m1 = mini(d1, id1);
    m2 = mini(d2, id2);
    m3 = mini(d3, id3);
    m4 = mini(d4, id4);
    int M;
    M = max(max(m1, m2), max(m3, m4));
    printf("%d\n", M);
  }
  return 0;
}
