#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long LLINF = 1e18;
static const double pi = 3.141592653589793;
int dif(int a, int b) {
  int d = abs(a - b);
  return min(d, 24 - d);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> nums(N);
  for (int i = 0; i < N; i++) cin >> nums[i];
  nums.push_back(0);
  sort(nums.begin(), nums.end());
  int mn = INF, pre = -1;
  for (auto& a : nums) {
    if (pre == -1) {
      pre = a;
    } else {
      mn = min(mn, dif(pre, a));
      pre = (pre > a ? a : (24 - a) % 24);
    }
  }
  cout << mn << endl;
  ;
}
