#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]);
    }
    MIN = 24;
    if (n == 1) MIN = 0;
    for (int i = 0; i < n - 1; i++) {
      t1 = fabs(a[i + 1] - a[i]);
      t2 = fabs(24 - a[i + 1] - a[i]);
      if (t1 < t2)
        MIN = min(MIN, t2);
      else
        MIN = min(MIN, t1);
    }
    printf("%d\n", MIN);
  }
}
