#include <bits/stdc++.h>
using namespace std;
int diff(int a, int b) {
  if (a == 0 && b == 0) {
    return 0;
  }
  int c = 24 - a;
  int d = 24 - b;
  return max(abs(a - b), max(abs(a - d), max(abs(c - b), abs(c - d))));
}
int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  int ans = diff(0, d[0]);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      ans = min(ans, diff(d[i], d[j]));
    }
  }
  cout << ans << endl;
  return 0;
}
