#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int d[100] = {0};
  for (int i = 1; i <= n; i++) cin >> d[i];
  int ans = *min_element(d + 1, d + n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int tmp1 = abs(d[i] - d[j]);
      int tmp2 = abs(d[i] - (24 - d[j]));
      int tmp3 = max(tmp1, tmp2);
      int tmp4 = min(tmp3, 24 - tmp3);
      ans = min(ans, tmp4);
    }
  }
  cout << ans << endl;
  return 0;
}
