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(); // dp[i] := 最大公約数がiである部分列の選び方 let mut ans: u64 = 0; for i in 0..n { let mut dp = std::collections::HashMap::new(); dp.insert(1, 0); dp.insert(a[i], 1); for j in i + 1..n { let mut dp_tmp = std::collections::HashMap::new(); for (&k, &v) in dp.iter() { let num = dp_tmp.entry(gcd(k, a[j])).or_insert(0); *num += v; let num = dp_tmp.entry(k).or_insert(0); *num += v; } for (&k, &v) in dp_tmp.iter() { let num = dp.entry(k).or_insert(v); *num = v; } } ans += dp[&1]; } println!("{}", ans); }