#include "cstdio"
#include "map"
#define N 1000100
int f[N], n, a[N], maxn, s[N];
namespace IAKIOI {
const int L = 1 << 20 | 1;
char buffer[L], *S, *TT;
// #define getchar() ((S==TT&&(TT=(S=buffer)+fread(buffer,1,L,stdin),S==TT))?EOF:*S++)
inline void read(int &x) {
x = 0;
int f = 1;
char s = getchar();
while (s < '0' || s > '9') {
if (s == '-')
f = -1;
s = getchar();
}
while (s >= '0' && s <= '9') {
x = x * 10 + s - '0';
s = getchar();
}
x *= f;
}
inline void write(int x) {
if (x < 0) {
putchar('-');
x = -x;
}
if (x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
}
using namespace IAKIOI;
int main() {
read(n);
for (int i = 1; i <= n; i++) {
read(a[i]);
s[a[i]]++;
maxn = std::max(maxn, a[i]);
}
for (int i = 1; i <= maxn; i++)
if (s[i])
for (int j = i; j <= maxn; j += i)
f[j] += s[i];
for (int i = 1; i <= n; i++)
write(f[a[i]] - 1), puts("");
return 0;
}