#include using namespace std; bool isPrime(long int 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 (long int i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return false; return true; } long int longestSequence(vector a){ long int c=0; int n=a.size(); for(int i=0;isum; long int temp=a[i]; sum.push_back(temp); while(temp!=1){ long int j=2; bool check=isPrime(temp); if(check==true){ sum.push_back(1); break; } while(j!=temp+1) { if(temp%j==0) { temp=temp/j; sum.push_back(temp); break; } j++; } } vector::iterator it=sum.begin(); long int s; while(it!=sum.end()) { c=c+(*it); it++; } } } return c; } int main() { int n; cin >> n; vector a(n); for(int a_i = 0; a_i < n; a_i++){ cin >> a[a_i]; } long int result = longestSequence(a); cout << result << endl; return 0; }