#include <bits/stdc++.h>
const int INF = 1000;
int abs(int a) {
  if (a > 0) return a;
  return -a;
}
int min(int a, int b) {
  if (a > b) return b;
  return a;
}
int max(int a, int b) {
  if (a > b) return a;
  return b;
}
int main() {
  int n, a[10000], top;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  top = a[0];
  for (int i = 0; i < n - 1; i++)
    top = min(top, max(abs(a[i + 1] - a[i]), abs(24 - a[i + 1] - a[i])));
  printf("%d\n", top);
}
