Language: C++

#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 1000003
using namespace std;
  
typedef long long ll;
const int mod = 1000000007;
  
int prime[MAX];
unordered_map<int, int> max_map;
  
// Function to return a^n
int power(int a, int n)
{
    if (n == 0)
        return 1;
    int p = power(a, n / 2) % mod;
    p = (p * p) % mod;
    if (n & 1)
        p = (p * a) % mod;
    return p;
}
  
// Function to find the smallest prime factors
// of numbers upto MAX
void sieve()
{
    prime[0] = prime[1] = 1;
    for (int i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}
  
// Function to return the LCM modulo M
ll lcmModuloM(const int* ar, int n)
{
  
    for (int i = 0; i < n; i++) {
        int num = ar[i];
        unordered_map<int, int> temp;
  
        // Temp stores mapping of prime factor to
        // its power for the current element
        while (num > 1) {
  
            // Factor is the smallest prime factor of num
            int factor = prime[num];
  
            // Increase count of factor in temp
            temp[factor]++;
  
            // Reduce num by its prime factor
            num /= factor;
        }
  
        for (auto it : temp) {
  
            // Store the highest power of every prime
            // found till now in a new map max_map
            max_map[it.first] = max(max_map[it.first], it.second);
        }
    }
  
    ll ans = 1;
  
    for (auto it : max_map) {
  
        // LCM is product of primes to their highest powers modulo M
        ans = (ans * power(it.F, it.S)) % mod;
    }
  
    return ans;
}

// C function for extended Euclidean Algorithm (used to
// find modular inverse.
ll gcdExtended(ll a, int ll, int *x, int *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }
  
    int x1, y1; // To store results of recursive call
    ll gcd = gcdExtended(b%a, a, &x1, &y1);
  
    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;
  
    return gcd;
}
  
// Function to find modulo inverse of b. It returns
// -1 when inverse doesn't
ll modInverse(ll b, ll m)
{
    ll x, y; // used in extended GCD algorithm
    ll g = gcdExtended(b, m, &x, &y);
  
    // Return -1 if b and m are not co-prime
    if (g != 1)
        return -1;
  
    // m is added to handle negative x
    return (x%m + m) % m;
}
  
// Function to compute a/b under modlo m
ll modDivide(ll a, ll b, ll m)
{
    a = a % m;
    ll inv = modInverse(b, m);
    if (inv <= -1)
    {
        return inv+m;
    }
    else
    {
        return (inv * a) % m;
    }
}
  

  
  
int main()
{
    sieve();
    int n;
    int a[100009];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll lcm = lcmModuloM(a, n);
    
    ll ans = 0;
    for(int i=0;i<n;i++){
        ans = (ans + modDivide(a[i],lcm,mod))%mod
    }
    cout<<ans<<"\n";
    return 0;
}



Compiler output:
a.cc: In function 'll gcdExtended(ll, int, int*, int*)':
a.cc:91:16: error: 'b' was not declared in this scope
   91 |         return b;
      |                ^
a.cc:95:7: error: expected ';' before 'gcd'
   95 |     ll gcd = gcdExtended(b%a, a, &x1, &y1);
      |       ^~~~
      |       ;
a.cc:99:16: error: 'b' was not declared in this scope
   99 |     *x = y1 - (b/a) * x1;
      |                ^
a.cc:102:12: error: cannot resolve overloaded function 'gcd' based on conversion to type 'll' {aka 'long long int'}
  102 |     return gcd;
      |            ^~~
a.cc: In function 'll modInverse(ll, ll)':
a.cc:110:30: error: cannot convert 'll*' {aka 'long long int*'} to 'int*'
  110 |     ll g = gcdExtended(b, m, &x, &y);
      |                              ^~
      |                              |
      |                              ll* {aka long long int*}
a.cc:85:35: note:   initializing argument 3 of 'll gcdExtended(ll, int, int*, int*)'
   85 | ll gcdExtended(ll a, int ll, int *x, int *y)
      |                              ~~~~~^
a.cc: In function 'int main()':
a.cc:151:50: error: expected ';' before '}' token
  151 |         ans = (ans + modDivide(a[i],lcm,mod))%mod
      |                                                  ^
      |                                                  ;
  152 |     }
      |     ~