#include <bits/stdc++.h>
using namespace std;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int D[N];
  int cnt[24] = {};
  int rnd[24] = {};
  for (int i = 0; i < N; i++) cin >> D[i];
  for (int i = 0; i < N; i++) cnt[D[i]]++;
  cnt[0]++;
  for (int i = 0; i < N; i++) {
    if (cnt[i] >= 3) {
      cout << "0" << endl;
      return 0;
    }
  }
  for (int i = 0; i < 24; i++) {
    if (cnt[0] >= 2) {
      cout << "0" << endl;
      return 0;
    }
    if (cnt[i] == 2) {
      cnt[i]--;
      cnt[24 - i]++;
    }
  }
  int ANS = 0;
  for (int k = 0; k < 500; k++) {
    int ans = 24;
    int A = 0, B = 0;
    int flag = 0;
    int tmp = 0;
    for (int i = 0; i < 24; i++) {
      flag = 0;
      if (cnt[i] != 0) A = i;
      for (int j = i + 1; j < 24; j++) {
        if (cnt[j] != 0) {
          B = j;
          flag = 1;
          break;
        }
      }
      if (flag == 1) {
        if (ans >= abs(A - B)) {
          ans = abs(A - B);
          if (cnt[24 - A] == 0) {
            rnd[tmp++] = A;
          }
          if (cnt[24 - B] == 0) {
            rnd[tmp++] = B;
          }
        }
      }
    }
    for (int i = 0; i < 24; i++) {
      if (cnt[i] != 0) {
      }
    }
    ANS = max(ans, ANS);
    if (tmp >= 1) {
      int T = rand() % tmp;
      cnt[rnd[T]]--;
      cnt[24 - rnd[T]]++;
    }
  }
  cout << ANS << endl;
  return 0;
}
