#include<bits/stdc++.h> #define ll long long usingnamespace std;
constint N = 1e5 + 66;
int n, q, tot, las; int a[N], cnt[N * 5]; int rec[N * 5][10]; bool vis[N * 5];
inlinevoidyhm_div(int pos) { int i, x = a[pos]; for (i = 2; i * i <= x; ++ i) { if (x % i == 0) { rec[a[pos]][++ rec[a[pos]][0]] = i; while (x % i == 0) x /= i; } } if (x > 1) rec[a[pos]][++ rec[a[pos]][0]] = x; return; }
inlineintfunc(int x) { int i, j, res(0), MAXSTATE = (1 << rec[x][0]); for (i = 1; i < MAXSTATE; ++ i) { int tmp = 1, num = 0; for (j = 0; j < rec[x][0]; ++ j) if (i & (1 << j)) tmp *= rec[x][j + 1], ++ num; res += (num & 1) ? cnt[tmp] : -cnt[tmp]; } return res; }
inlinevoidupdata(int x, int delta) { int i, j, MAXSTATE = (1 << rec[x][0]); for (i = 1; i < MAXSTATE; ++ i) { int tmp = 1; for (j = 0; j < rec[x][0]; ++ j) if (i & (1 << j)) tmp *= rec[x][j + 1]; cnt[tmp] += delta; } return; }
signedmain() { int i, x, add; n = read(), q = read(); for (i = 1; i <= n; ++ i) a[i] = read(); for (i = 1; i <= n; ++ i) if (! rec[a[i]][0]) yhm_div(i);