import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop; void main() { auto N = readln.chomp.to!int; auto A = readln.split.map!(to!int).array; auto cnt = new int[](10^^6+1); foreach (a; A) { for (int i = 1; i * i <= a; ++i) if (a % i == 0) { cnt[i] += 1; if (i * i != a) cnt[a/i] += 1; } } auto X = iota(10^^6+1).map!(i => tuple(i, cnt[i])).array; X = X.filter!(x => x[1] != 0).array; X.sort!((a, b) => a[1] == b[1] ? a[0] < b[0] : a[1] > b[1]); int idx = 0; foreach (k; 0..N) { while (idx + 1 < X.length && X[idx+1][1] >= N - k) ++idx; X[idx][0].writeln; } }