Language: C++

#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k, n) for (ll i = k; i <= (ll)(n); ++i)
#define MAX 100010
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans, cnt;

// a^n mod を計算する
ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % MOD;
		a = a * a % MOD;
		n >>= 1;
	}
	return res;
}

// 素因数分解
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) { // √n以下にしか約数(素数)はない
		while (n % i == 0) { // 小さい数(2)からスタートすることで必ず素数のみがこのループに入る
			ret[i]++; // 何回割り切れるのかで何条か判断する
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1; // 最後に残った数を追加
	return ret;
}


int main() {
	ll N;
	cin  >> N;
	
	vector<ll> A(N);
	rep(i, N) {
		cin >> A[i];
	}

	map<ll, ll> lcm{};
	rep(i, N) {
		ll x = A[i];
		for (ll j = 2; j*j <= x; j++) {
			if (x % j == 0) {
				ll cnt = 0;
				while (x % j == 0) {
					cnt++;
					x /= j;
				}
				lcm[j] = max(lcm[j], cnt);
			}
		}
		if (x != 1) {
			lcm[x] = max(lcm[x], 1);
		}
	}

	rep(i, N) {
		map<ll, ll> apr = prime_factor(A[i]);
		ll temp = 1;

		
		for (auto pr : lcm) {
			temp *= modpow(pr.first, pr.second - apr[pr.first]);
			temp %= MOD;
		}
		
		// cout << "temp:" << temp << endl;
		ans += temp;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:60:37: error: no matching function for call to 'max(std::map<long long int, long long int>::mapped_type&, int)'
   60 |                         lcm[x] = max(lcm[x], 1);
      |                                  ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:60:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   60 |                         lcm[x] = max(lcm[x], 1);
      |                                  ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:60:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   60 |                         lcm[x] = max(lcm[x], 1);
      |                                  ~~~^~~~~~~~~~~