#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int d[n + 1];
  d[0] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> d[i];
  }
  vector<int> diff;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j <= n; j++) {
      diff.push_back(max(abs(d[i] - d[j]), abs(24 - d[i] - d[j]) % 24));
    }
  }
  cout << *min_element(diff.begin(), diff.end()) << "\n";
  return 0;
}
