Language: C++

#include <bits/stdc++.h>
using namespace std;

const int64_t mod=1e9+7;
map< int64_t, int64_t > ans;
map< int64_t, int64_t > prime_factor(int64_t n) {
  map< int64_t, int64_t > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n]++;
  return ret;
}
int64_t modpow(int64_t a, int64_t b){
	int64_t res = 1;
	while (b > 0){
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b /= 2;
	}
	return res;
}
int main(){
    int n;
    cin >> n;
    int64_t a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        for(auto u:prime_factor(a[i])){
            ans[u.first]=max(ans[u.first],u.second);
        }
    }
    int64_t solve=0;
    int64_t tmp; 
    for(int i=0;i<n;i++){
        tmp=1;
        map< int64_t, int64_t > tmp_pri=prime_factor(a[i]);
        for(auto u:ans){
            tmp*=modpow(u.first,max(0,u.second-tmp_pri[u.first]))
        }
        solve += tmp;
        solve %= mod;
    }    
    cout << solve << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:42:36: error: no matching function for call to 'max(int, long int)'
   42 |             tmp*=modpow(u.first,max(0,u.second-tmp_pri[u.first]))
      |                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:42:36: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   42 |             tmp*=modpow(u.first,max(0,u.second-tmp_pri[u.first]))
      |                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:42:36: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   42 |             tmp*=modpow(u.first,max(0,u.second-tmp_pri[u.first]))
      |                                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~