#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int D[55], N;
string s;
int s1, s2;
int main() {
  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++) {
    if (i % 2) {
      D[i] = (24 - D[i]) % 24;
    }
  }
  sort(D, D + N + 1);
  int mn = 23;
  for (int i = 0; i < N; i++) {
    mn = min(mn, min(D[i + 1] - D[i], 24 - (D[i + 1] - D[i])));
  }
  cout << (mn) << endl;
  return 0;
}
