#include <bits/stdc++.h>
using namespace std;
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  long long n;
  cin >> n;
  ;
  vector<long long> data(n);
  for (long long i = 0; i < n; i++) {
    cin >> data[i];
    if (!data[i]) {
      cout << 0 << endl;
      return 0;
    }
  }
  sort((data).begin(), (data).end());
  vector<long long> yui;
  yui.push_back(0);
  for (long long i = 0; i < data.size(); i++) {
    if (i % 2) {
      yui.push_back(data[i]);
    } else {
      yui.push_back(24 - data[i]);
    }
  }
  sort((yui).begin(), (yui).end());
  long long ans = 1001000100010001000;
  for (long long i = 1; i < yui.size(); i++) {
    ans = min(ans, yui[i] - yui[i - 1]);
  }
  vector<long long> kyoko;
  kyoko.push_back(0);
  for (long long i = 0; i < data.size(); i++) {
    if (i % 2) {
      kyoko.push_back(24 - data[i]);
    } else {
      kyoko.push_back(data[i]);
    }
  }
  sort((kyoko).begin(), (kyoko).end());
  long long yuikyo = 1001000100010001000;
  for (long long i = 1; i < kyoko.size(); i++) {
    yuikyo = min(yuikyo, kyoko[i] - kyoko[i - 1]);
  }
  cout << max(ans, yuikyo) << endl;
  return 0;
}
