#include <bits/stdc++.h>
static FILE *szpFpI;
static int si1DF[55];
static int siDCnt;
static char sc1Time[24];
static int siMax;
int fOutLine(char *pcpLine) {
  char lc1Buf[1024];
  printf("%s", pcpLine);
  return 0;
}
int fSortFncIu(const void *pzpVal1, const void *pzpVal2) {
  int *lipVal1 = (int *)pzpVal1;
  int *lipVal2 = (int *)pzpVal2;
  if (*lipVal1 > *lipVal2) {
    return 1;
  } else if (*lipVal1 < *lipVal2) {
    return -1;
  }
  return 0;
}
int fSrhTime(int piSNo) {
  int i;
  for (i = piSNo;; i++) {
    if (i >= 24) {
      i = 0;
    }
    if (sc1Time[i] == 1) {
      return i;
    }
  }
  return 0;
}
int fSetTime(int piDNo) {
  if (piDNo >= siDCnt) {
    int liStart = fSrhTime(0);
    int liNow = liStart;
    int liMin = INT_MAX;
    while (1) {
      int liNext = fSrhTime(liNow + 1);
      int liTime = abs(liNext - liNow);
      if (liMin > liTime) {
        liMin = liTime;
      }
      if (liNext == liStart) {
        break;
      }
      liNow = liNext;
    }
    if (siMax < liMin) {
      siMax = liMin;
    }
    return 0;
  }
  int liDF = si1DF[piDNo];
  if (sc1Time[liDF] == 0) {
    sc1Time[liDF] = 1;
    fSetTime(piDNo + 1);
    sc1Time[liDF] = 0;
  }
  liDF = (24 - si1DF[piDNo]) % 24;
  if (sc1Time[liDF] == 0) {
    sc1Time[liDF] = 1;
    fSetTime(piDNo + 1);
    sc1Time[liDF] = 0;
  }
  return 0;
}
int fMain() {
  int i;
  char lc1Buf[1024];
  memset(sc1Time, 0, sizeof(sc1Time));
  siMax = 0;
  fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
  sscanf(lc1Buf, "%d", &siDCnt);
  si1DF[0] = 0;
  for (i = 1; i <= siDCnt; i++) {
    fscanf(szpFpI, "%d", &si1DF[i]);
  }
  siDCnt++;
  fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
  qsort(si1DF, siDCnt, sizeof(int), fSortFncIu);
  fSetTime(0);
  return 0;
}
int fOne() {
  int liRet;
  char lc1Buf[1024];
  szpFpI = stdin;
  liRet = fMain();
  sprintf(lc1Buf, "%d\n", siMax);
  fOutLine(lc1Buf);
  return 0;
}
int main() {
  fOne();
  return 0;
}
