#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;
  s1 = 24;
  sort(D, D + N + 1);
  if (D[1] == 0) s1 = s2 = 12;
  for (int i = 0; i < N + 1; i++) {
    if (i % 2) {
      s1 = min(s1, (24 - D[i]));
    } else {
      s2 = max(s2, D[i]);
    }
  }
  cout << (s1 - s2) << endl;
  return 0;
}
