#include <bits/stdc++.h>
using namespace std;
int a[510000];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] != 0)
      a[i + n] = 24 - a[i];
    else
      a[i + n] = 0;
  }
  sort(a + 1, a + 2 * n + 1);
  int max1 = 0;
  for (int i = 2; i <= 2 * n; i++) {
    max1 = max(max1, a[i] - a[i - 1]);
  }
  cout << max1 << endl;
}
