#include <bits/stdc++.h>
using namespace std;
int n, arr[105], b[105], m, ans;
void f(int x) {
  int y, i;
  if (x == n) {
    sort(b, b + m);
    y = (b[m - 1] - b[0]);
    x = 24 - (b[m - 1] - b[0]);
    y = y > x ? x : y;
    for (i = 1; i < m; i++) {
      x = b[i] - b[i - 1];
      y = y > x ? x : y;
      x = 24 - x;
      y = y > x ? x : y;
    }
    ans = ans < y ? y : ans;
    return;
  }
  if (x + 1 < n && arr[x] == arr[x + 1]) {
    b[m++] = arr[x];
    b[m++] = 24 - arr[x];
    f(x + 2);
    m -= 2;
  } else {
    b[m++] = arr[x];
    f(x + 1);
    b[m - 1] = 24 - arr[x];
    f(x + 1);
    m--;
  }
}
int main() {
  int i;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
  }
  arr[n++] = 0;
  sort(arr, arr + n);
  if (n > 1 && arr[0] == arr[1]) {
    printf("0\n");
    return 0;
  }
  for (i = 0; i < n - 2; i++) {
    if (arr[i] == arr[i + 1] && arr[i + 1] == arr[i + 2]) {
      printf("0\n");
      return 0;
    }
  }
  f(0);
  printf("%d\n", ans);
  return 0;
}
