#include<cstdio> usingnamespace std; typedeflonglong LL; constint mod = 1e9 + 7; intbinpow(int b, int k) { int res = 1; while (k) { (k & 1) && (res = (LL) res * b % mod); b = (LL) b * b % mod; k >>= 1; } return res; } intphi(int x) { int res = x; for (int i = 2; i * i <= x; i++) if (x % i == 0) { res = res / i * (i - 1); while (x % i == 0) x /= i; } x > 1 && (res = res / x * (x - 1)); return res; } intmain() { int T; scanf("%d", &T); for (int n; T; T--) { scanf("%d", &n); int res = 0; for (int i = 1; i <= n / i; i++) if (n % i == 0) { (res += (LL)binpow(n, i) * phi(n / i) % mod) %= mod; i * i != n && ((res += (LL)binpow(n, n / i) * phi(i) % mod) %= mod); } printf("%lld\n", (LL) res * binpow(n, mod - 2) % mod); } return0; }