#include <bits/stdc++.h>
using namespace std;
signed main(void) {
  long long N;
  long long D[57];
  cin >> N;
  D[0] = 0;
  for (long long i = 0; i < (N); ++i) {
    cin >> D[i + 1];
  }
  long long Ans = 1145141919810893364;
  sort(D, D + N + 1);
  for (long long i = 0; i < (N + 1); ++i) {
    if (i % 2 == 1) D[i] = 24 - D[i];
    if (D[i] == 24) D[i] = 0;
  }
  for (long long i = 0; i < (N + 1); ++i) {
    for (long long j = 0; j < (N + 1); ++j) {
      if (i <= j) continue;
      Ans = min(Ans, abs(D[i] - D[j]));
    }
  }
  cout << Ans << endl;
  return 0;
}
