use std::collections::HashMap; const LIMIT: usize = 1e6 as usize; fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: Vec = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let mut mapping = HashMap::new(); for &v in a.iter() { *mapping.entry(v).or_insert(0usize) += 1; } let mut used_cnt = vec![0usize; LIMIT + 1]; for (&v, &cnt) in mapping.iter() { for j in 1..=(v as f64).sqrt().floor() as usize { if v % j == 0 { let l = j; let r = v/j; used_cnt[l] += cnt; if l != r { used_cnt[r] += cnt; } } } } let mut result = vec![0usize; n]; for i in (1..=LIMIT).rev() { if used_cnt[i] == 0 { continue; } let mut idx = n-used_cnt[i]; while idx < n && result[idx] == 0 { result[idx] = i; idx += 1; } } for &v in result.iter() { println!("{}", v); } }