use std::io::Read; fn main() { let mut all_data = String::new(); std::io::stdin().read_to_string(&mut all_data).ok(); let all_data: Vec<&str> = all_data.trim().split('\n').map(|a| a.trim()).collect(); let n: u128 = all_data.iter().next().unwrap().parse::().unwrap(); let mut result = 1; all_data.iter().skip(1).next().unwrap().split_whitespace() .map(|a| a.parse::().unwrap() % 9) .map(|a| if a == 0 { 9 } else { a }) .for_each(|a| {result = (result * a) % 9;}); println!("{}", if result % 9 == 0 { 9 } else { result % 9 }); }