use std::io::Read; fn gcd(a: u32, b: u32) -> u32 { if b == 0 {a} else {gcd(b, a % b)} } fn run() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); let mut it = s.trim().split_whitespace(); let n: usize = it.next().unwrap().parse().unwrap(); let a: Vec = (0..n).map(|_| it.next().unwrap().parse().unwrap()).collect(); let mut dp = std::collections::BTreeMap::::new(); for a in a { let mut next = dp.clone(); for (k, v) in dp { let k = gcd(k, a); *next.entry(k).or_insert(0) += v; } *next.entry(a).or_insert(0) += 1; dp = next; } if let Some(&v) = dp.get(&1) { println!("{}", v); } else { println!("0"); } } fn main() { run(); }