intmain() { for (int i = 1; i <= n; ++ i) for (int j = 1, x = a[i]; j <= x / j; ++ j) { if (x % j) continue; bs[j].push_back(i); if (j * j != x) bs[x / j].push_back(i); } for (d = 1; d < N; ++ d) { for (int x : bs[d]) if (!vis[x]) dfs(x); for (int x : bs[d]) vis[x] = false; } for (int i = N - 1; i; -- i) for (int j = 2; j * i < N; ++ j) adj(ans[i] -= ans[i * j]); int res = 0; for (int i = 1; i < N; ++ i) res = (res + (LL) i * ans[i]) % Mod; std::cout << res << std::endl; return0; }