#include <bits/stdc++.h>
using namespace std;
int inv(int h) {
  if (h == 0) return 0;
  return 24 - h;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int hour[24] = {};
  hour[12]++;
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    hour[(12 + d) % 24]++;
  }
  for (int i = 0; i < 24; i++) {
    if (hour[i] > 2) {
      cout << 0 << endl;
      return 0;
    } else if (hour[i] == 2) {
      hour[i]--;
      hour[inv(i)]++;
    }
  }
  for (int d = 1; d <= 12; d++) {
    for (int h = 0; h < 24; h++) {
      if (hour[h] == 0) continue;
      for (int k = h - d; k <= h + d; k++) {
        int hc = (k + 24) % 24;
        if (hc == h) continue;
        if (hour[hc] == 0) continue;
        if (hour[inv(hc)] > 0) {
          cout << d << endl;
          return 0;
        } else {
          for (int l = inv(hc) - d; l <= inv(hc) + d; l++) {
            int hcc = (l + 24) % 24;
            if (hour[hcc] > 0) {
              cout << d << endl;
              return 0;
            }
          }
          hour[hc]--;
          hour[inv(hc)]++;
        }
      }
    }
  }
  return 0;
}
