use std::io::Read; fn g(a: u64, b: u64) -> u64 { if b == 0 { a } else { g(b, a % b) } } fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let n: Vec = s.split_whitespace().flat_map(str::parse).collect(); let mut a = 0; for i in 1..n.len() - 2 { for j in i + 1..n.len() - 1 { let d = g(n[i], n[j]); if d == 1 { a += n.len() - j - 1; continue; } for k in j + 1..n.len() { if g(d, n[k]) == 1 { a += 1; } } } } println!("{a}") }