#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

// n^m
struct PowerPermutation { n: usize, m: usize, ar: Vec<usize> }
impl PowerPermutation {
    fn new(n: usize, m: usize) -> PowerPermutation {
        let ar = vec![0; m];
        PowerPermutation { n: n, m: m, ar: ar }
    }
}
impl Iterator for PowerPermutation {
    type Item = Vec<usize>;
    fn next(&mut self) -> Option<Vec<usize>> {
        if self.ar[self.m-1] >= self.n { return None }
        let r = self.ar.clone();
        self.ar[0] += 1;
        for i in 0..self.m-1 {
            if self.ar[i] == self.n {
                self.ar[i] = 0;
                self.ar[i + 1] += 1;
            } else {
                break;
            }
        }
        return Some(r);
    }
}
fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut count = vec![0; 13];
    count[0] = 1;
    for _ in 0..n {
        let d: usize = sc.cin();
        count[d] += 1;
    }
    for i in 1..12 {
        if count[i] >= 3 {
            put!(0);
            return;
        }
    }
    for &i in [0, 12].iter() {
        if count[i] >= 2 {
            put!(0);
            return;
        }
    }

    fn df(x: usize, y: usize) -> usize {
        if x <= y {
            min!(y - x, 24 + x - y)
        } else {
            df(y, x)
        }
    }

    let mut ans = 0;
    for p in PowerPermutation::new(2, 11) {
        let mut d: Vec<usize> = vec![];
        if count[0] > 0 { d.push(0); }
        if count[12] > 0 { d.push(12); }
        for k in 0..11 {
            if count[k + 1] == 2 {
                d.push(k+1);
                d.push(23-k);
            } else if count[k + 1] == 1 {
                if p[k] == 0 {
                    d.push(k+1);
                } else {
                    d.push(23-k);
                }
            }
        }
        trace!(&d);
        let m = d.len();
        ans = max!(
            ans,
(0..m-1).map(|i| (i+1..m).map(|j| df(d[i], d[j])).min().unwrap() ).min().unwrap()
            );
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352