use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut n = s.split_whitespace().skip(1).flat_map(str::parse::); let mut a = -1; for d in 0..12 { if n.clone() .any(|t| matches!((t + 12 - d) % 12, 1 | 3 | 6 | 8 | 10)) { continue; } if a != -1 { a = -1; break; } a = d as i8; } println!("{a}") }