#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, d[51];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  d[n] = 0;
  sort(d, d + n + 1);
  for (int i = 0; i < n + 1; i += 2) {
    d[i] = (24 - d[i]) % 24;
  }
  sort(d, d + n + 1);
  int r = 24 + d[0] - d[n];
  for (int i = 1; i < n + 1; i++) {
    r = min(r, d[i + 1] - d[i]);
  }
  cout << min(r, 24 - r) << endl;
  return 0;
}
