#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 K1) {
  int m = a[0];
  for (int i = 0; i < K1; 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[51];
  int nD[51];
  int rT[51][2];
  int d1[2050], d2[2050], d3[2050], d4[2050];
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &D[i]);
  }
  D[N] = 0;
  int label[24] = {0};
  for (int i = 0; i < N + 1; i++) {
    if (label[D[i]] == 0) {
      label[D[i]] += 1;
      nD[i] = D[i];
    } else {
      label[24 - D[i]] += 1;
      nD[i] = 24 - D[i];
    }
  }
  label[0] = 1;
  for (int i = 0; i < N + 1; i++) {
    rT[i][0] = nD[i];
    rT[i][1] = 24 - nD[i];
  }
  int id = 0;
  int t1, t2, t3, t4, t;
  for (int i = 0; i < N + 1; i++) {
    for (int j = 0; j < N + 1; j++) {
      if (i != j) {
        t1 = timeGap(rT[i][0], rT[j][0]);
        t2 = timeGap(rT[i][0], rT[j][1]);
        t3 = timeGap(rT[i][1], rT[j][0]);
        t4 = timeGap(rT[i][1], rT[j][1]);
        t = max(max(t1, t2), max(t3, t4));
        d1[id++] = t;
      }
    }
  }
  int M = mini(d1, id);
  printf("%d\n", M);
  return 0;
}
