#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, 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];
  int f = 0, s1, s2;
  for (int i = (1); i < (n); ++i) {
    if (f == 0) {
      s1 = d[i] - dr[i - 1];
      s2 = dr[i] - d[i - 1];
    } else {
      s2 = d[i] - dr[i - 1];
      s1 = dr[i] - d[i - 1];
    }
    if (s1 < 0) s1 = -s1;
    if (s2 < 0) s2 = -s2;
    if (sm1 > s1) sm1 = s1;
    if (sm2 > s2) sm2 = s2;
    f = (f + 1) % 2;
  }
  sm1 = sm1 % 12;
  sm2 = sm2 % 12;
  smax = sm1 > sm2 ? sm1 : sm2;
  cout << smax << endl;
  return 0;
}
