use std::io::*; fn gcd(a: u64, b: u64) -> u64 { if b == 0 { return a; } 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 = std::collections::HashMap::new(); dp.insert(0, 1); for i in 0..n { let mut next = std::collections::HashMap::new(); for (&value, &count) in dp.iter() { // use let g = gcd(value, a[i]); let val = next.entry(g).or_insert(0); *val += count; // not use let val = next.entry(value).or_insert(0); *val += count; } dp = next; dp.entry(a[i]).or_insert(1); } let val = dp.entry(1).or_insert(0); println!("{}", *val); }