#include <bits/stdc++.h>
using namespace std;
const int MAXN = 0;
int d[100];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> d[i];
  sort(d, d + n + 1);
  for (int i = 0; i <= n; i++) {
    if (i % 2 == 1) {
      d[i] = 24 - d[i];
    }
  }
  int ans = 228;
  for (int i = 0; i <= n; i++) {
    ans = min(ans, abs(d[i] - d[(i + 1) % (n + 1)]) % 24);
  }
  cout << ans;
  return 0;
}
