#include <bits/stdc++.h>
typedef struct {
  int t, num;
} City;
int comp(const void* a, const void* b) { return ((City*)a)->t - ((City*)b)->t; }
int d[50];
City city[100];
int used[50];
int n;
int check(int s) {
  int now = s, cnt = 0, i;
  memset(used, 0, sizeof(used));
  for (i = (0); i < (2 * n); i++) {
    if (city[i].t < now) continue;
    if (!used[city[i].num]) {
      used[city[i].num] = 1;
      cnt++;
      now = city[i].t + s;
    }
  }
  return cnt == n;
}
int main(void) {
  int left, right, mid, i;
  scanf("%d", &n);
  for (i = (0); i < (n); i++) {
    scanf("%d", d + i);
    city[i * 2].t = d[i];
    city[i * 2].num = i;
    city[i * 2 + 1].t = (24 - d[i]) % 24;
    city[i * 2 + 1].num = i;
  }
  qsort(city, n * 2, sizeof(City), comp);
  ;
  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;
}
