#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        mut d: [usize; n],
    }
    d.push(0);
    d.sort();

    let mut map = HashMap::new();
    for i in 0..d.len() {
        let x = d[i];
        *map.entry(x).or_insert(0) += 1;
    }
    let mut times = vec![];
    let mut utimes = vec![];

    for (k, v) in map.iter() {
        if *v >= 3 || *v == 2 && *k == 0 {
            println!("{}", 0);
            return;
        } else if *v == 2 {
            times.push(*k);
            times.push(24 - *k);
            times.push(*k + 24);
            times.push(24 - *k + 24);
        } else {
            utimes.push(*k);
        }
    }

    let mut ans = 0;
    for i in 0..1 << utimes.len() {
        let mut ctimes = times.clone();
        for j in 0..utimes.len() {
            if (i >> j) & 1 == 1 {
                ctimes.push(utimes[j]);
                ctimes.push(utimes[j] + 24);
            } else {
                ctimes.push(24 - utimes[j]);
                ctimes.push(24 - utimes[j] + 24);
            }
        }
        let set = ctimes.into_iter().collect::<std::collections::HashSet<_>>();
        let mut v = set.into_iter().collect::<Vec<_>>();
        v.sort();

        let mut t = 24;
        for i in 1..v.len() {
            t = min(t, v[i] - v[i - 1]);
        }
        ans = max(ans, t);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352