#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int D[N];
  for (int i = 0; i < N; ++i) cin >> D[i];
  int time[24];
  fill(time, time + 24, 0);
  time[0] = 1;
  for (int i = 0; i < N; ++i) {
    if (time[D[i]] == 0)
      ++time[D[i]];
    else if (D[i] != 0 && time[24 - D[i]] == 0)
      ++time[24 - D[i]];
    else {
      cout << "NO" << endl;
      return 0;
    }
  }
  int ans = 24, l = -24;
  for (int i = 0; i < 24; ++i) {
    if (time[i]) {
      ans = min(ans, i - l);
      l = i;
    }
  }
  cout << ans << endl;
  return 0;
}
