#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  if (n == 1) {
    cout << v[0] << endl;
    return 0;
  }
  int Min = 10000;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i == j) continue;
      int dif = abs(v[i] - v[j]);
      int dif2 = abs(24 - v[i] - v[j]);
      int tmp = max(dif, dif2);
      Min = min(dif2, Min);
    }
  }
  for (int i = 0; i < n; i++) {
    Min = min(Min, v[i]);
  }
  cout << Min << endl;
  return 0;
}
