Language: C++

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using PL = pair<ll,ll>;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
constexpr int INF = (1 << 29);
constexpr ll INF_ = (1LL << 58);
constexpr ld EPS = (1e-10);
constexpr ld PI_ = 3.141592653589793238;//46264338327950288
constexpr ld E_ = 2.71828182845904523;//5360287471352
constexpr ll MOD = 1000000007;
//// functions (integer)_________________________________
ll modpow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a % m;
		a = a * a%m; n >>= 1;
	}
	return res;
}
long long modinv(long long a, long long p, long long mod){
  return modpow(a,p-2,mod);
}
////-----------------------------------------------------



int main(){
  int N;vector<ll> A; set<ll>P; map<ll,ll> B;
  cin >> N;
  RPT(i,0,N){
    ll a; cin >> a;
    A.push_back(a);
  }
  sort(A.begin(),A.end());

  FOR(i,2,1000003){
    bool ynprime = true;
    for(auto x : P){
      if(i % x == 0){ ynprime = false; break; }
      if( x*x > i ) break;
    }
    if(ynprime) P.insert(i);
  }

  RPT(i,0,N){
    ll ttl = A[i];
    iterator it = P.lower_bound(A[i]);
    if(it!=P.end() && P[it]==A[i]){
      ttl = 1;
      if(B[A[i]]<1) B[A[i]] = 1;
    }
    for(auto x : P){
      ll cnt = 0;
      if(x > A[i] || ttl == 1) break;
      while(ttl % x == 0){
        ttl /= x;
        cnt++;
      }
      if(cnt){
        if(B[x]<cnt) B[x] = cnt;
      }
    }
    if(ttl != 1) {
      P.insert(A[i]);
      B[A[i]] = 1;
    }
  }

  ll L=1, Ainv = 0;
  for(auto x : P){
    L = ((L * (modpow(x,B[x],MOD))%MOD)) % MOD;
  }
  RPT(i,0,N){
    Ainv = (Ainv + ((modpow(A[i],MOD-2,MOD)%MOD)%MOD) ) % MOD;
  }
  ll ans = (Ainv * L) % MOD;
  //ll ans = (Ainv % MOD);
  cout << ans << endl; 
  //cout << L << endl << Ainv << endl;for(auto x: P) if(B[x]) cout << x << "^" << B[x] << " ";
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:37: error: class template argument deduction failed:
   52 |     iterator it = P.lower_bound(A[i]);
      |                                     ^
a.cc:52:37: error: no matching function for call to 'iterator(std::set<long long int>::iterator)'
In file included from /usr/include/c++/14/bits/stl_algobase.h:65,
                 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_iterator_base_types.h:127:34: note: candidate: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> iterator()-> std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>'
  127 |     struct _GLIBCXX17_DEPRECATED iterator
      |                                  ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note: candidate: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> iterator(std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>)-> std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note:   template argument deduction/substitution failed:
a.cc:52:37: note:   'std::_Rb_tree_const_iterator<long long int>' is not derived from 'std::iterator<_Category, _Tp, _Distance, _Pointer, _Reference>'
   52 |     iterator it = P.lower_bound(A[i]);
      |                                     ^