#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a;
  a.push_back(0);
  for (int i = 0; n > i; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(), a.end());
  for (int i = 0; n > i; i += 2) {
    a[i] = 24 - a[i];
  }
  sort(a.begin(), a.end());
  int ans = 10000;
  for (int i = 1; n > i; i++) {
    ans = min(ans, a[i] - a[i - 1]);
  }
  cout << ans << endl;
}
