use std::io::Read; fn gcd(a: usize, b: usize) -> usize { 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 ans = 0; for i in 0..n { let mut dp = std::collections::HashMap::new(); dp.insert(a[i], 1); for j in i + 1..n { let mut tmp = std::collections::HashMap::new(); for (k, v) in &dp { let num = tmp.entry(gcd(*k, a[j])).or_default(); *num += v; let num = tmp.entry(*k).or_default(); *num += v; } dp = tmp; } ans += *dp.entry(1).or_default(); } println!("{}", ans); }