use std::collections::HashMap; use std::io::Read; fn gcd(a: u64, b: u64) -> u64 { if b == 0 { a } else { gcd(b, a % b) } } fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let a: Vec = (0..n) .map(|_| itr.next().unwrap().parse().unwrap()) .collect(); let mut dp: HashMap = HashMap::new(); for i in 0..n { let mut tmp: HashMap = HashMap::new(); for (k, v) in &dp { if *k == 0 { let num = tmp.entry(a[i]).or_default(); *num += v; } else { let num = tmp.entry(gcd(*k, a[i])).or_default(); *num += v; } let num = tmp.entry(*k).or_default(); *num += v; } dp = tmp; dp.entry(a[i]).or_insert(1); dp.entry(0).or_insert(1); } println!("{}", dp.entry(1).or_default()); }