#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; ++i) cin >> D[i];
  sort(begin(D), end(D));
  int res = D[0];
  int l = D[0], r = 0;
  for (int i = 1; i < N; ++i) {
    if (i % 2) {
      res = min(D[i] - r, 24 - l - D[i]);
      r = D[i];
    } else {
      res = min(D[i] - l, 24 - r - D[i]);
      l = D[i];
    }
  }
  cout << res << endl;
}
