#include <bits/stdc++.h>
int a[50];
using namespace std;
int main() {
  int n, t;
  int MAX, MIN, t1, t2;
  while (~scanf("%d", &n)) {
    for (int i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    MAX = 0;
    MIN = 24;
    for (int j = 0; j < 2; j++) {
      MIN = 24;
      for (int i = 0; i < n - 1; i++) {
        if (j == 0) t1 = fabs(a[i + 1] - a[i]);
        if (j == 1) t1 = fabs(24 - a[i + 1] - a[i]);
        MIN = min(MIN, t1);
      }
      MAX = max(MAX, MIN);
    }
    if (n == 1) MAX = 0;
    printf("%d\n", MAX);
  }
}
