#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> lp(N);
vector<bool> p(N, 1);
vector<vector<int>> pf(N), divisor(N);
int precompute() {
iota(lp.begin(), lp.end(), 0);
for (int i = 2; i < N; i++) {
if (p[i]) {
for (int j = i; j < N; j += i) {
lp[j] = min(lp[j], i);
if (i ^ j) p[j] = 0;
}
}
}
for (int i = 2; i < N; i++) {
for (int j = i; j < N; j += i) {
divisor[j].emplace_back(i);
}
}
for (int i = 2; i < N; i++) {
int x = i;
while (lp[x] > 1) {
int t = lp[x];
pf[i].push_back(t);
while (x % t == 0) {
x /= t;
}
}
}
return 0;
}
int pre = precompute();
int main() {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
vector<int> A(n);
for (int& x : A) cin >> x;
vector<int> cnt(N);
for (int i = 0; i < n; i++) {
for (int d : divisor[A[i]]) cnt[d]++;
}
vector<int> ans(n);
for (int i = 0; i < n; i++) {
vector<int> pr;
for (int p : pf[A[i]]) pr.emplace_back(p);
for (int d : divisor[A[i]]) cnt[d]--;
int k = pr.size();
// inclusion exclusion
for (int mask = 1; mask < 1 << k; mask++) {
int prod = 1;
for (int bit = 0; bit < k; bit++) {
if (mask >> bit & 1) prod *= pr[bit];
}
if (__builtin_popcount(mask) & 1) {
ans[i] += cnt[prod];
} else {
ans[i] -= cnt[prod];
}
}
for (int d : divisor[A[i]]) cnt[d]++;
}
for (int x : ans) cout << x << ' ';
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IGludCBOID0gMWU1ICsgNTsKdmVjdG9yPGludD4gbHAoTik7CnZlY3Rvcjxib29sPiBwKE4sIDEpOwp2ZWN0b3I8dmVjdG9yPGludD4+IHBmKE4pLCBkaXZpc29yKE4pOwoKaW50IHByZWNvbXB1dGUoKSB7CiAgaW90YShscC5iZWdpbigpLCBscC5lbmQoKSwgMCk7CiAgZm9yIChpbnQgaSA9IDI7IGkgPCBOOyBpKyspIHsKICAgIGlmIChwW2ldKSB7CiAgICAgIGZvciAoaW50IGogPSBpOyBqIDwgTjsgaiArPSBpKSB7CiAgICAgICAgbHBbal0gPSBtaW4obHBbal0sIGkpOwogICAgICAgIGlmIChpIF4gaikgcFtqXSA9IDA7CiAgICAgIH0KICAgIH0KICB9CiAgZm9yIChpbnQgaSA9IDI7IGkgPCBOOyBpKyspIHsKICAgIGZvciAoaW50IGogPSBpOyBqIDwgTjsgaiArPSBpKSB7CiAgICAgIGRpdmlzb3Jbal0uZW1wbGFjZV9iYWNrKGkpOwogICAgfQogIH0KCiAgZm9yIChpbnQgaSA9IDI7IGkgPCBOOyBpKyspIHsKICAgIGludCB4ID0gaTsKICAgIHdoaWxlIChscFt4XSA+IDEpIHsKICAgICAgaW50IHQgPSBscFt4XTsKICAgICAgcGZbaV0ucHVzaF9iYWNrKHQpOwogICAgICB3aGlsZSAoeCAlIHQgPT0gMCkgewogICAgICAgIHggLz0gdDsKICAgICAgfQogICAgfQogIH0KICByZXR1cm4gMDsKfSAKCmludCBwcmUgPSBwcmVjb21wdXRlKCk7CgoKaW50IG1haW4oKSB7CiAgY2luLnRpZSgwKS0+c3luY193aXRoX3N0ZGlvKDApOwogIAogIGludCBuOwogIGNpbiA+PiBuOwogIHZlY3RvcjxpbnQ+IEEobik7CiAgZm9yIChpbnQmIHggOiBBKSBjaW4gPj4geDsKCiAgdmVjdG9yPGludD4gY250KE4pOwogIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICBmb3IgKGludCBkIDogZGl2aXNvcltBW2ldXSkgY250W2RdKys7CiAgfQogIHZlY3RvcjxpbnQ+IGFucyhuKTsKICBmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewogICAgdmVjdG9yPGludD4gcHI7CiAgICBmb3IgKGludCBwIDogcGZbQVtpXV0pIHByLmVtcGxhY2VfYmFjayhwKTsKICAgIGZvciAoaW50IGQgOiBkaXZpc29yW0FbaV1dKSBjbnRbZF0tLTsKCiAgICBpbnQgayA9IHByLnNpemUoKTsKCQoJLy8gaW5jbHVzaW9uIGV4Y2x1c2lvbgogICAgZm9yIChpbnQgbWFzayA9IDE7IG1hc2sgPCAxIDw8IGs7IG1hc2srKykgewogICAgICBpbnQgcHJvZCA9IDE7CiAgICAgIGZvciAoaW50IGJpdCA9IDA7IGJpdCA8IGs7IGJpdCsrKSB7CiAgICAgICAgaWYgKG1hc2sgPj4gYml0ICYgMSkgcHJvZCAqPSBwcltiaXRdOwogICAgICB9CiAgICAgIGlmIChfX2J1aWx0aW5fcG9wY291bnQobWFzaykgJiAxKSB7CiAgICAgICAgYW5zW2ldICs9IGNudFtwcm9kXTsKICAgICAgfSBlbHNlIHsKICAgICAgICBhbnNbaV0gLT0gY250W3Byb2RdOwogICAgICB9CiAgICB9CiAgICBmb3IgKGludCBkIDogZGl2aXNvcltBW2ldXSkgY250W2RdKys7CiAgfQogIGZvciAoaW50IHggOiBhbnMpIGNvdXQgPDwgeCA8PCAnICc7CiAgcmV0dXJuIDA7Cn0=