#include using namespace std; typedef long long ll; #define rep(i, s, e) for(ll i = (s);i < (e);i++) #define repEqual(i, s, e) for(ll i = (s);i <= (e);i++) #define repZero(i, e) for(ll i = 0;i < (e);i++) #define mem(a,val) memset(a,val,sizeof a) const ll INF = (long long)2e9; const ll mod = (long long)1e7 + 19; #define MAX_N 10000000 //----------START--------------------------- bool prime[MAX_N+1]; long dp[MAX_N+1]; void SieveOfEratosthenes(ll n) { mem(prime,true); for (ll p=2; p*p <= n; p++) { // If prime[p] is not changed, then it is a prime if (prime[p] == true) { // Update all multiples of p for (ll i=p*2; i <= n; i += p) prime[i] = false; } } } bool isPrime(ll n) { // Corner cases if (n <= 1) return false; if (n <= 3) return true; // This is checked so that we can skip // middle five numbers in below loop if (n%2 == 0 || n%3 == 0) return false; for (ll i=5LL; i*i<=n; i=i+6LL) if (n%i == 0 || n%(i+2) == 0) return false; return true; } ll greatestDivisor(ll n) { repEqual(i,2,sqrt(n)) if(n % i == 0) return n/i; return 1; } ll compute(ll n) { if(n <= MAX_N){ if(dp[n] != 0) return dp[n]; if(prime[n]) return n + 1LL; ll temp = greatestDivisor(n); dp[n] = n + compute(temp); return dp[n]; } // Case when n > MAX_N if(isPrime(n)) return n + 1LL; ll temp = greatestDivisor(n); return n + compute(temp); } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); SieveOfEratosthenes(MAX_N); dp[1] = 1; dp[0] = 0; int n; cin>>n; ll query[n]; repZero(i,n) cin>>query[i]; sort(query,query+n); ll ans = 0; repZero(i,n){ ans+= compute(query[i]); } cout<