#include <bits/stdc++.h>
using namespace std;
priority_queue<int> que;
int main() {
  int N, D[50], DD[50];
  scanf("%d", &N);
  if (N == 1) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < N; i++) {
    scanf(" %d", &D[i]);
    DD[i] = D[i];
    if (D[i] == 0) {
      printf("0\n");
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    int MIN = 12;
    DD[i] = 24 - D[i];
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      MIN = min(MIN, abs(DD[i] - D[j]));
    }
    DD[i] = D[i];
    for (int j = 0; j < N; j++) {
      if (i == j) continue;
      if (DD[i] == D[j]) continue;
      MIN = min(MIN, abs(DD[i] - D[j]));
    }
    for (int i = 0; i < N; i++) {
      MIN = min(MIN, D[i]);
    }
    que.push(MIN);
  }
  printf("%d\n", que.top());
  return 0;
}
