#include using namespace std; vector prime; const int MAXN = 2000000; bool isPrimes[MAXN+200]; long long longestSequence(vector a) { memset(isPrimes, true, sizeof(isPrimes)); for(int i=2;i*i<=MAXN;i++) if(isPrimes[i]) for(int j=i*i;j<=MAXN;j+=i) isPrimes[j] = false; for(int i=2;i<=MAXN;i++) if(isPrimes[i]) prime.push_back(i); long long ans = 0; for(int i=0;i ps; for(int j=0;j=0;j--) { x *= ps[j]; ans += x; } } return ans; } int main() { int n; cin >> n; vector a(n); for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } long long result = longestSequence(a); cout << result << endl; return 0; }