Language: C++

/*
ID: yzshang1
LANG: C++11
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
const int N = 10010, MOD = 1e9 + 7;
long long a[N], n;
const int M = 1000010;
map <int, int> F, f[N];
LL qpow(LL a, LL b, LL p = MOD) {
	LL ans = 1;
	for (; b; b >>= 1) {
		if (b & 1) ans = ans * a % p;
		a = a * a % p;
	}
	return ans;
}
void debugPrint(map <int, int> m) {
	for (auto i:m) {
		cout << "{" << i.first << "," << i.second << "} ";
	}
	cout << endl;
} 
void fact(int id, LL x) {
	LL y = x;
	for (int i = 2; i <= y; i++) {
		int cnt = 0;
		while (x % i == 0) {
			x /= i;
			cnt++;
		}
		if (cnt) f[id][i] = cnt;
	}
//	debugPrint(f[id]);
	for (auto x:f[id]) {
		if (!F.count(x.first)) F.insert(mp(x.first, x.second));
		else F[x.first] = max(F[x.first], x.second);
	}
}

int main() {
	cin >> n;
	repn(i, n) cin >> a[i], fact(i, a[i]);
	LL ans = 0, res = 0;
//	debugPrint(F);
	repn(i, n) {
		res = 1;
		for (auto j:F) {
			res = (res * qpow(j.first,(j.second - f[i][j.first]))) % MOD;
		}
//		cerr << res << endl;
		ans = (ans + res) % MOD;
	}
//	cerr << endl;
	cout << ans << endl;
	return 0;
}
/*
ID: yzshang1
LANG: C++11
TASK:
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int (i) = 1; (i) <= (int)n; (i)++)
#define rep(i, n) for (int (i) = 0; (i) < (int)n; (i)++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
const int N = 10010, MOD = 1e9 + 7;
long long a[N], n;
const int M = 1000010;
map <int, int> F, f[N];
LL qpow(LL a, LL b, LL p = MOD) {
	LL ans = 1;
	for (; b; b >>= 1) {
		if (b & 1) ans = ans * a % p;
		a = a * a % p;
	}
	return ans;
}
void debugPrint(map <int, int> m) {
	for (auto i:m) {
		cout << "{" << i.first << "," << i.second << "} ";
	}
	cout << endl;
} 
void fact(int id, LL x) {
	LL y = x;
	for (int i = 2; i <= y; i++) {
		int cnt = 0;
		while (x % i == 0) {
			x /= i;
			cnt++;
		}
		if (cnt) f[id][i] = cnt;
	}
//	debugPrint(f[id]);
	for (auto x:f[id]) {
		if (!F.count(x.first)) F.insert(mp(x.first, x.second));
		else F[x.first] = max(F[x.first], x.second);
	}
}

int main() {
	cin >> n;
	repn(i, n) cin >> a[i], fact(i, a[i]);
	LL ans = 0, res = 0;
//	debugPrint(F);
	repn(i, n) {
		res = 1;
		for (auto j:F) {
			res = (res * qpow(j.first,(j.second - f[i][j.first]))) % MOD;
		}
//		cerr << res << endl;
		ans = (ans + res) % MOD;
	}
//	cerr << endl;
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc:83:11: error: redefinition of 'const int INF'
   83 | const int INF = 0x3f3f3f3f;
      |           ^~~
a.cc:15:11: note: 'const int INF' previously defined here
   15 | const int INF = 0x3f3f3f3f;
      |           ^~~
a.cc:84:19: error: redefinition of 'const long double EPS'
   84 | const long double EPS = 1e-6;
      |                   ^~~
a.cc:16:19: note: 'const long double EPS' previously defined here
   16 | const long double EPS = 1e-6;
      |                   ^~~
a.cc:85:11: error: redefinition of 'const int N'
   85 | const int N = 10010, MOD = 1e9 + 7;
      |           ^
a.cc:17:11: note: 'const int N' previously defined here
   17 | const int N = 10010, MOD = 1e9 + 7;
      |           ^
a.cc:85:22: error: redefinition of 'const int MOD'
   85 | const int N = 10010, MOD = 1e9 + 7;
      |                      ^~~
a.cc:17:22: note: 'const int MOD' previously defined here
   17 | const int N = 10010, MOD = 1e9 + 7;
      |                      ^~~
a.cc:86:11: error: redefinition of 'long long int a [10010]'
   86 | long long a[N], n;
      |           ^
a.cc:18:11: note: 'long long int a [10010]' previously declared here
   18 | long long a[N], n;
      |           ^
a.cc:86:17: error: redefinition of 'long long int n'
   86 | long long a[N], n;
      |                 ^
a.cc:18:17: note: 'long long int n' previously declared here
   18 | long long a[N], n;
      |                 ^
a.cc:87:11: error: redefinition of 'const int M'
   87 | const int M = 1000010;
      |           ^
a.cc:19:11: note: 'const int M' previously defined here
   19 | const int M = 1000010;
      |           ^
a.cc:88:16: error: redefinition of 'std::map<int, int> F'
   88 | map <int, int> F, f[N];
      |                ^
a.cc:20:16: note: 'std::map<int, int> F' previously declared here
   20 | map <int, int> F, f[N];
      |                ^
a.cc:88:19: error: redefinition of 'std::map<int, int> f [10010]'
   88 | map <int, int> F, f[N];
      |                   ^
a.cc:20:19: note: 'std::map<int, int> f [10010]' previously declared here
   20 | map <int, int> F, f[N];
      |                   ^
a.cc:89:4: error: redefinition of 'LL qpow(LL, LL, LL)'
   89 | LL qpow(LL a, LL b, LL p = MOD) {
      |    ^~~~
a.cc:21:4: note: 'LL qpow(LL, LL, LL)' previously defined here
   21 | LL qpow(LL a, LL b, LL p = MOD) {
      |    ^~~~
a.cc:97:6: error: redefinition of 'void debugPrint(std::map<int, int>)'
   97 | void debugPrint(map <int, int> m) {
      |      ^~~~~~~~~~
a.cc:29:6: note: 'void debugPrint(std::map<int, int>)' previously defined here
   29 | void debugPrint(map <int, int> m) {
      |      ^~~~~~~~~~
a.cc:103:6: error: redefinition of 'void fact(int, LL)'
  103 | void fact(int id, LL x) {
      |      ^~~~
a.cc:35:6: note: 'void fact(int, LL)' previously defined here
   35 | void fact(int id, LL x) {
      |      ^~~~
a.cc:120:5: error: redefinition of 'int main()'
  120 | int main() {
      |     ^~~~
a.cc:52:5: note: 'int main()' previously defined here
   52 | int main() {
      |     ^~~~