#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[55];
  int n;
  cin >> n;
  int mini = 10000, ans = 10000;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= n; j++) {
      if (i == j) continue;
      int x = max(abs(a[j] - a[i]), abs(24 - a[j] - a[i]));
      if (x < mini) mini = x;
    }
    ans = min(ans, mini);
  }
  if (ans == 10000)
    cout << 0 << endl;
  else
    cout << ans << endl;
  return 0;
}
