#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } #include using mint = atcoder::modint1000000007; ostream& operator<<(ostream& os, const mint& m){ os << m.val(); return os; } const int N = 1000000; using P = pair; vector

facs[N]; void init(){ vector v(N+1); iota(v.begin(), v.end(), 0); for(int p = 2; p <= N; p++){ for(int i = 1; i*p <= N; i++){ int cnt = 0; while(v[i*p]%p == 0){ cnt++; v[i*p] /= p; } if(cnt > 0) facs[i*p].push_back({p, cnt}); } } } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; init(); int n; cin >> n; vector a(n); vector> st(N+1); mint all_prod = 1; for(int i = 0; i < n; i++) { cin >> a[i]; all_prod *= a[i]; for(auto [p, c]: facs[a[i]]){ st[p].insert(c); } } mint all_lcm = 1; for(int x = 1; x <= N; x++){ if(st[x].empty()) continue; int mx = *prev(st[x].end()); all_lcm *= mint(x).pow(mx); } for(int i = 0; i < n; i++){ mint p = all_prod/a[i]; mint l = all_lcm; for(auto [p, c]: facs[a[i]]){ int cur_max = *prev(st[p].end()); st[p].erase(st[p].find(c)); int erased_max = st[p].empty() ? 0 : *prev(st[p].end()); l /= mint(p).pow(cur_max-erased_max); st[p].insert(c); } cout << (p-l) << endl; } }