Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD int(1e9+7)
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 10005

ll add(ll a,ll b)
{
	a%=MOD; b%=MOD;
	a+=b;a%=MOD;
	if(a<0) a+=MOD;
	return a;
}
ll mult(ll a, ll b)
{
	a%=MOD; b%=MOD;
	ll ans=(a*b)%MOD;
	if(ans<0) ans+=MOD;
	return ans;
}
ll pw(ll a, ll b)
{
	ll r=1;
	while(b){
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
ll inverse(ll a)
{
	return pw(a,MOD-2);
}
void getpf(map<ll,ll>& pf, ll n)
{
	for(ll i=2; i*i<=n; i++)
	{
		int cnt=0;
		while(n%i==0){
			n/=i; cnt++;
		}
		if(cnt>0) pf[i]=cnt;
	}
	if(n>1) pf[n]=1;
}

int n;
ll a[MAXN];
unordered_map<ll,ll> pf[MAXN];
unordered_map<ll,ll> lcm;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin>>n;
	forn(i,0,n) cin>>a[i];
	
	forn(i,0,n){
		getpf(pf[i],a[i]);
		for(ii tmp: pf[i]){
			lcm[tmp.F]=max(lcm[tmp.F],tmp.S);
		}
	}
	
	ll ans=0;
	forn(i,0,n){
		ll cur=1;
		for(auto tmp: lcm){
			ll p=tmp.F, c=tmp.S;
			if(pf[i].find(p)==pf[i].end()) cur=mult(cur, pw(p,c));
			else cur=mult(cur, pw(p,c-pf[i][p]));
		}
		ans=add(ans, cur);
	}
	
	cout<<ans<<'\n';
	
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:83:27: error: invalid initialization of reference of type 'std::map<long long int, long long int>&' from expression of type 'std::unordered_map<long long int, long long int>'
   83 |                 getpf(pf[i],a[i]);
      |                       ~~~~^
a.cc:57:24: note: in passing argument 1 of 'void getpf(std::map<long long int, long long int>&, ll)'
   57 | void getpf(map<ll,ll>& pf, ll n)
      |            ~~~~~~~~~~~~^~
a.cc:85:25: error: reference to 'lcm' is ambiguous
   85 |                         lcm[tmp.F]=max(lcm[tmp.F],tmp.S);
      |                         ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:73:22: note:                 'std::unordered_map<long long int, long long int> lcm'
   73 | unordered_map<ll,ll> lcm;
      |                      ^~~
a.cc:85:40: error: reference to 'lcm' is ambiguous
   85 |                         lcm[tmp.F]=max(lcm[tmp.F],tmp.S);
      |                                        ^~~
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:73:22: note:                 'std::unordered_map<long long int, long long int> lcm'
   73 | unordered_map<ll,ll> lcm;
      |                      ^~~
a.cc:92:31: error: reference to 'lcm' is ambiguous
   92 |                 for(auto tmp: lcm){
      |                               ^~~
/usr/include/c++/14/numeric:188:5: note: candidates are: 'template<class _Mn, class _Nn> constexpr std::common_type_t<_Mn, _Nn> std::lcm(_Mn, _Nn)'
  188 |     lcm(_Mn __m, _Nn __n) noexcept
      |     ^~~
a.cc:73:22: note:                 'std::unordered_map<long long int, long long int> lcm'
   73 | unordered_map<ll,ll> lcm;
      |                      ^~~
a.cc:94:75: error: 'c' was not declared in this scope
   94 |                         if(pf[i].find(p)==pf[i].end()) cur=mult(cur, pw(p,c));
      |                                                                           ^
a.cc:95:49: error: 'c' was not declared in this scope
   95 |                         else cur=mult(cur, pw(p,c-pf[i][p]));
      |                                                 ^