#include <bits/stdc++.h>
using namespace std;
using ll = int;
int norm(int m, int n) { return min(abs(n - m), 24 - abs(n - m)); }
int main(void) {
  int n;
  cin >> n;
  vector<int> d;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    d.push_back(x);
  }
  int iru[24] = {0};
  iru[0] = 1;
  for (int i = 0; i < n; i++) {
    int a = d[i];
    int b = 24 - d[i];
    int amin = 24;
    int bmin = 24;
    for (int j = 0; j < 24; j++) {
      if (iru[j]) {
        amin = min(amin, norm(a, j));
      }
    }
    for (int j = 0; j < 24; j++) {
      if (iru[j]) {
        bmin = min(bmin, norm(b, j));
      }
    }
    if (amin == 0 && bmin == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (amin >= bmin || d[i] == 0) {
      iru[a] = 1;
    } else {
      iru[b] = 1;
    }
  }
  int M = 0;
  int Max = 24;
  vector<int> irus;
  for (int i = 0; i < 24; i++) {
    if (iru[i]) {
      irus.push_back(i);
    }
  }
  irus.push_back(24);
  for (int i = 0; i < irus.size() - 1; i++) {
    Max = min(irus[i + 1] - irus[i], Max);
  }
  cout << Max << endl;
  return 0;
}
