#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long MAX = 200005;
int n, m, t = 0;
char b[9] = {'A', 'K', 'I', 'H', 'A', 'B', 'A', 'R', 'A'};
char s[100005];
int a[5] = {0}, MIN = 24;
int main() {
  scanf("%d", &n);
  if (n == 1) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  sort(a, a + n);
  for (int i = n - 1; i >= 0; i = i - 2) {
    a[i] = 24 - a[i];
  }
  sort(a, a + n);
  for (int i = 1; i < n; i++) {
    if (a[i] - a[i - 1] < MIN) MIN = a[i] - a[i - 1];
  }
  printf("%d\n", MIN);
  return 0;
}
