#include <bits/stdc++.h>
using namespace std;
string binal(int k) {
  string res;
  for (int i = 0, i_len = (23); i < i_len; ++i) {
    res += char('0' + k % 2);
    k /= 2;
  }
  return res;
}
int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  vector<int> A(13, 0);
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    cin >> D[i];
    if (D[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
    A[D[i]]++;
    if (A[i] >= 3) {
      cout << 0 << endl;
      return 0;
    }
  }
  int ans = 23;
  vector<bool> B(25, false);
  B[24] = B[0] = true;
  bool left = true;
  for (int i = 0, i_len = (13); i < i_len; ++i) {
    if (A[i] == 2) {
      B[i] = true;
      B[24 - i] = true;
    } else if (A[i] == 1) {
      if (left)
        B[i] = true;
      else
        B[24 - i] = true;
      left = !left;
    }
  }
  int tmp = 24;
  for (int i = 0, i_len = (25); i < i_len; ++i) {
    if (!B[i])
      tmp++;
    else {
      ans = min(ans, tmp + 1);
      tmp = 0;
    }
  }
  cout << ans << endl;
}
