#include <bits/stdc++.h>
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
using namespace std;
int main() {
  int cal[13][13] = {};
  for (int i = 0; i < 13; ++i) {
    for (int j = i; j < 13; ++j) {
      cal[i][j] =
          max(min(abs(i - j), i + 24 - j),
              min(abs((24 - i) - j), min(24 - i, j) + 24 - max(24 - i, j)));
      cal[j][i] = cal[i][j];
    }
  }
  int n;
  int d[51] = {};
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &d[i + 1]);
  }
  int ans = 24;
  for (int i = 0; i < n + 1; ++i) {
    for (int j = i + 1; j < n + 1; ++j) {
      ans = min(ans, cal[d[i]][d[j]]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
