#include <bits/stdc++.h>
using namespace std;
const double pi =
    3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod = 1000000007;
int main() {
  int n, d[52] = {}, dr[52] = {}, i, j, k, sm1 = 24, sm2 = 24, sm3 = 24,
         smax = 0;
  cin >> n;
  for (int i = (1); i < (n + 1); ++i) {
    cin >> d[i];
  }
  n++;
  sort(d, d + n);
  for (int i = (0); i < (n); ++i) dr[i] = 24 - d[i];
  d[n] = 24;
  int f = 0, s1, s2, s3;
  for (int i = (1); i < (n); ++i) {
    if (f == 0) {
      s1 = d[i] - dr[i - 1];
      s2 = dr[i] - d[i - 1];
      if (s1 < -12) s1 += 24;
    } else {
      s2 = d[i] - dr[i - 1];
      s1 = dr[i] - d[i - 1];
      if (s1 > 12) s1 -= 24;
    }
    if (n >= 2) {
      s3 = d[i] - d[i - 2];
    }
    if (s1 < 0) s1 = -s1;
    if (s2 < 0) s2 = -s2;
    if (sm1 > s1) sm1 = s1;
    if (sm2 > s2) sm2 = s2;
    if (sm1 > s3) sm1 = s3;
    if (sm2 > s3) sm2 = s3;
    f = (f + 1) % 2;
  }
  smax = sm1;
  if (n == 2) smax = d[1];
  for (int i = (1); i <= (12); ++i) {
    if (upper_bound(d, d + n, i) - lower_bound(d, d + n, i) >= 3) smax = 0;
  }
  cout << smax << endl;
  return 0;
}
