#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, num[50], counts[24] = {0}, i, now, ans = 0, tmp, x;
  cin >> n;
  if (n > 23) {
    puts("0");
    return 0;
  }
  for (i = 0, x = 24; i < n; i++) {
    cin >> num[i];
    if (num[i] == 0) {
      puts("0");
      return 0;
    }
    counts[num[i]]++;
    if (counts[num[i]] == 3) {
      puts("0");
      return 0;
    }
  }
  for (now = (1 << n) - 1, counts[0] = 1; now >= 0; now--) {
    for (i = 1; i < 24; i++) counts[i] = 0;
    for (i = 0, tmp = now; i < n; tmp /= 2, i++)
      if (tmp & 1) {
        if (counts[24 - num[i]])
          break;
        else
          counts[24 - num[i]]++;
      } else {
        if (counts[num[i]])
          break;
        else
          counts[num[i]]++;
      }
    if (i < n) continue;
    for (i = 1, tmp = 0, x = 24; i < 24 && x != 1; i++)
      if (counts[i]) x = min(x, i - tmp), tmp = i;
    ans = max(x, ans);
  }
  cout << ans << "\n";
}
