#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  if (N == 1)
    cout << 0 << endl;
  else {
    int all[N];
    int x[13] = {0};
    for (int i = 0; i < N; i++) cin >> all[i];
    for (int i = 0; i < N; i++) {
      x[all[i]]++;
    }
    bool check;
    for (int i = 0; i < 13; i++) {
      if (x[i] > 2) check = false;
    }
    int ans = 0;
    if (check) {
      vector<int> test;
      for (int i = 0; i < 1 << 13; i++) {
        test.clear();
        for (int j = 0; j < 13; j++) {
          if ((i >> j & 1) == 1 && x[j] == 1)
            test.push_back(j);
          else if ((i >> j & 1) == 0 && x[j] == 1)
            test.push_back(24 - j);
          else if (x[j] == 2) {
            test.push_back(j);
            test.push_back(24 - j);
          }
        }
        test.push_back(0);
        sort(test.begin(), test.end());
        int temp = 24;
        for (int j = 0; j < test.size() - 1; j++)
          temp = min(temp, test[j + 1] - test[j]);
        ans = max(ans, temp);
      }
      cout << ans << endl;
    } else
      cout << 0 << endl;
  }
  return 0;
}
