#include using namespace std; vector prime; int arr[1000001] = { 0 }; void sieve() { int i, j; for(i = 2; i <= sqrt(1000001); i++) { if(arr[i]) continue; for(j = i; i * j <= 1000001; j++) { if(!arr[i * j]) arr[i * j] = 1; } } for(i = 2; i <= 1000000; i++) if(!arr[i]) prime.push_back(i); } long long getans(long long no) { int i = 0, ctr = 0; long long ans = 0, ite = (no / 2 < 1000001 ? no / 2: 1000001); if(no == 1) return 1; for(i = ite; i >= 2; i--) { if(arr[i] == 0 && no % i == 0) { ans += 1 + getans(no / i) * i; // printf("i : %d\tans = %d\n", i, ans); ctr = 1; break; } } if(ctr == 0) ans += 1 + no; return ans; } int main(int argc, char const *argv[]) { sieve(); int t; scanf("%d", &t); long long no = 0, sum = 0; while(t--) { scanf("%lld", &no); sum += getans(no); } printf("%lld\n", sum); return 0; }