use std::io;
use std::cmp;

fn main() {
    let n = read_values::<usize>()[0];
    let d = read_values::<usize>();
    assert!(n <= 23);


    {
        let mut count = vec![0; 13];
        for e in &d {
            count[*e] += 1;
        }

        if count[0] >= 1 {
            println!("0");
            return;
        }

        for c in &count {
            if *c >= 3 {
                println!("0");
                return;
            }
        }
        if count[12] >= 2 {
            println!("0");
            return;
        }
    }
    let mut max = 0;
    for mask in 0..(1 << n) {
        let mut v = vec![0; n + 1];
        for i in 0..n {
            if ((1 << i) & mask) != 0 {
                v[i] = d[i] as i32;
            } else {
                v[i] = -(d[i] as i32);
            }
        }

        v.sort();
        let mut min = 12;
        for i in 0..(n + 1) {
            if i == n {
                min = cmp::min(min, v[0] + 24 - v[i]);
            } else {
                min = cmp::min(min, v[i + 1] - v[i]);
            }
        }

        max = cmp::max(max, min);
    }
    println!("{}", max);
}

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}

fn read<T>() -> T
    where T: std::str::FromStr,
          T::Err: std::fmt::Debug
{
    read_line().trim().parse().unwrap()
}

fn read_values<T>() -> Vec<T>
    where T: std::str::FromStr,
          T::Err: std::fmt::Debug
{
    read_line()
        .split(' ')
        .map(|a| a.trim().parse().unwrap())
        .collect()
}