use std::collections::*; fn main() { let n = read::(); let t = read_vec::(); let mut cands = vec![]; for i in 0..12 { let d = vec![i, i + 2, i + 4, i + 5, i + 7, i + 9, i + 11] .into_iter() .map(|x| x % 12) .collect::>(); if t.iter().all(|&x| d.contains(&x)) { cands.push(i); } } if cands.len() != 1 { println!("-1"); return; } println!("{}", cands[0]); } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }