Language: C++

#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <deque>
#include <functional>
#include <initializer_list>
#include <math.h>
#include <map>
#include <random>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

// グリッド上の縦横移動
constexpr std::array<std::pair<int, int>, 4> dxdy = {
    std::pair<int, int>( 1,  0),
    std::pair<int, int>(-1,  0),
    std::pair<int, int>( 0,  1),
    std::pair<int, int>( 0, -1)
};

void VintOut(std::vector<int>& A){
    const int n = A.size();
    if(n == 0){putchar('\n'); return;}
    printf("%d", A[0]);
    for(int i = 1; i < n; ++i) printf(" %d", A[i]);
    putchar('\n');
}
void VintOut(std::vector<long long int>& A){
    const int n = A.size();
    if(n == 0){ putchar('\n'); return;}
    printf("%lld", A[0]);
    for(int i = 1; i < n; ++i) printf(" %lld", A[i]);
    putchar('\n');
}

template <typename T>
inline bool chmin(T& a, T b){
    if(b < a){ a = b; return true;}
    return false;
}

template <typename T>
inline bool chmax(T& a, T b){
    if(a < b){ a = b; return true;}
    return false;
}

inline bool isIn(int x, int y, int H, int W){
    return 0 <= x and x < H and 0 <= y and y < W;
}
inline bool bitUP(int state, int k){ return (state >> k) & 1; }
inline bool bitUP(long long int state, int k){ return (state >> k) & 1;}

// z-algorithm
template <class T> std::vector<int> z_algorithm(const T &str) {
    const int n = str.size();
    std::vector<int> resOfCP(n); resOfCP[0] = n;
    int i = 1, j = 0;
    while (i < n) {
        while (i + j < n and str[j] == str[i + j]) ++j;
        resOfCP[i] = j;
        if (j == 0) { ++i; continue;}
        int k = 1;
        while (i + k < n and k + resOfCP[k] < j) resOfCP[i + k] = resOfCP[k], ++k;
        i += k; j -= k;
    }
    return resOfCP;
}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


template <unsigned int modulus> struct modint{
    int val; // 値本体

    // コンストラクタ
    constexpr modint():val(0){}
    template <class T> constexpr modint(T v){
        val = v % (int)(modulus); 
        if(val < 0) val += modulus;
    }
    constexpr modint& operator+= (const modint<modulus> other) noexcept {
        val += other.val; if(val >= modulus) val -= modulus;
        return *this;
    }
    constexpr modint& operator -= (const modint<modulus> other) noexcept {
        val -= other.val; if(val < 0) val += modulus;
        return *this;
    }
    constexpr modint& operator *= (const modint<modulus> other) noexcept {
        val = (unsigned long long int)(val) * other.val % modulus;
        return *this; 
    }
    constexpr modint& operator /= (const modint<modulus> other) noexcept {
        val = (unsigned long long int)(val) * other.inverse() % modulus;
        return *this;
    }
    constexpr modint operator +(const modint<modulus> v)const noexcept{
        return modint<modulus>(*this) += v;
    }
    constexpr modint operator -(const modint<modulus> v)const noexcept{
        return modint<modulus>(*this) -= v;
    }
    constexpr modint operator *(const modint<modulus> v)const noexcept{
        return modint<modulus>(*this) *= v;
    }
    constexpr modint operator /(const modint<modulus> v)const noexcept{
        return modint<modulus>(*this) /= v;
    }
    constexpr modint& operator ++(void) noexcept {
        if(++val == modulus) val = 0;
        return *this;
    }
    constexpr modint& operator --(void) noexcept {
        if(val-- == 0) val = modulus - 1;
        return *this;
    }
    constexpr modint operator -()const noexcept{
        return modint<modulus>((val == 0 ? 0 : modulus - val));
    }

    // aの逆元を求める関数
    constexpr unsigned int inverse(unsigned int a) const noexcept {
        unsigned int b = modulus;
                 int u = 1,   v = 0;
        while (b != 0) {
            unsigned int t = a / b; 
            a -= t * b; std::swap(a, b);
            u -= t * v; std::swap(u, v);
        }
        if(u < 0) u += modulus;
        return u;
    }
    constexpr unsigned int inverse(void) const noexcept {return inverse(val);}
    // a^nを返す関数 : nは負の数でも可
    constexpr unsigned int power(unsigned long long int a, long long int n)const noexcept{
        if(n == 0) return 1;
        unsigned long long res = 1, waiting = a;
        if(n < 0) waiting = inverse(), n = -n;
        while(n != 0){ 
            if((n & 1UL) != 0){ res *= waiting; res %= modulus; }
            waiting *= waiting; waiting %= modulus; 
            n /= 2;
        }
        return res;
    }
    constexpr unsigned int power(long long int n) const noexcept {return power(val, n);}
};

template <unsigned int N> struct shuumai{
    unsigned int minPrime[N + 1];
    unsigned int Primes[N + 1];
    unsigned int size_;

    constexpr shuumai(void): minPrime(), Primes(), size_(0U){
        minPrime[0] = 1; minPrime[1] = 1;
        for(int even = 2, odd = 3; odd <= N; even += 2, odd += 2){
            minPrime[even] = 2;
            minPrime[odd] = odd;
        }
        if(!(N & 1)) minPrime[N] = 2;
        Primes[size_++] = 2;

        for(int x = 3; x <= N; x += 2) if(minPrime[x] == x){
            Primes[size_++] = x;
            for(int y = 0; y < size_ and Primes[y] <= minPrime[x] and x * Primes[y] <= N; ++y)
                    minPrime[x * Primes[y]] = Primes[y];
        }
    }
    // 範囲for文用の begin() と end()
    const unsigned int *begin(void) const noexcept{ return Primes; }
    const unsigned int *end(void) const noexcept{ return Primes + size_;}
    const unsigned int size(void) const {return this.size_;}
};


constexpr int MAX = 1e6;
constexpr int mod = 1e9 + 7;
std::array<int, MAX + 1> Count;
constexpr shuumai<N> P;
std::vector<int> A;

int main(void){
    using mint = modint<mod>;
    mint res = 0;

    int n; scanf("%d", &n);
    A.resize(n);
    REP(i, n){
        int a; scanf("%d", &a); A[i] = a;
        res += mint(mint(a).inverse());
        int fac = 0, cnt = 0;
        while(a != 1){
            int f = P.minPrime[a]; a /= f;
            if(fac != f){
                if(Count[fac] < cnt) Count[fac] = cnt;
                fac = f; cnt = 1;
            }
            else{
                cnt++;
            }
        }
        if(fac != 1){
            if(Count[fac] < cnt) Count[fac] = cnt;
        }
    }

    mint X = 1;
    for(int x = 2; x <= MAX; ++x) if(Count[x] > 0){
        X *= mint(x).power(Count[x]);
    }
    res *= X;
    printf("%d\n", res.val);




    
    
    return 0;
}


Compiler output:
a.cc:199:19: error: 'N' was not declared in this scope
  199 | constexpr shuumai<N> P;
      |                   ^
a.cc:199:20: error: template argument 1 is invalid
  199 | constexpr shuumai<N> P;
      |                    ^
a.cc:199:22: error: uninitialized 'const P' [-fpermissive]
  199 | constexpr shuumai<N> P;
      |                      ^
a.cc: In function 'int main()':
a.cc:213:23: error: request for member 'minPrime' in 'P', which is of non-class type 'const int'
  213 |             int f = P.minPrime[a]; a /= f;
      |                       ^~~~~~~~