#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  int p = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') p = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    x = (x << 1) + (x << 3) + (c ^ '0');
    c = getchar();
  }
  x *= p;
}
int n;
int d[60];
bool ok(int x) {
  int minn = 0x7f7f7f7f;
  for (int i = 1; i <= n; i++) {
    if (d[i + 1] - d[i] >= 0) minn = min(minn, d[i + 1] - d[i]);
    if (24 - d[i + 1] - d[i] >= 0) minn = min(minn, 24 - d[i + 1] - d[i]);
    if (24 - d[i + 1] - 24 + d[i] >= 0)
      minn = min(minn, 24 - d[i + 1] - 24 + d[i]);
    if (d[i + 1] - 24 + d[i] >= 0) minn = min(minn, d[i + 1] - 24 + d[i]);
  }
  if (minn == x) return 1;
  return 0;
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(d[i]);
  int l = 0, r = 24;
  int ans = 0;
  d[n + 1] = d[1];
  if (n == 1) return puts("0"), 0;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (ok(mid))
      l = mid + 1, ans = max(ans, mid);
    else
      r = mid - 1;
  }
  printf("%d\n", ans);
  return 0;
}
