#include #include #include #include #include #include #include using namespace std; class BIT { vector tree; long size = 0; long maxVal; public: long read(int idx) { long sum = 0; while (idx > 0) { sum += tree[idx]; idx -= (idx & -idx); } return sum; } void insert(int idx) { size++; while (idx <= maxVal) { tree[idx] += 1; idx += (idx & -idx); } } BIT(int maxVal) { tree = vector(maxVal+1, 0); this->maxVal = maxVal; } long getSize() { return size; } }; #define p 1000001 long breakupBar(vector &primes, long barLength) { long count = 0; long mult = 1; bool smacked = false; for (int j = 0; j < primes.size(); j++) { while(barLength % primes[j] == 0 && barLength > 1) { smacked = true; long otherSide = barLength/primes[j]; if (otherSide > primes[j]) { count += breakupBar(primes, otherSide); barLength = barLength/otherSide; mult = mult*otherSide; } else { barLength /= primes[j]; count += mult; mult = mult*primes[j]; } } } if (smacked == false && barLength > 1) { count++; } return count; } int main() { int n; scanf("%d", &n); vector bars(n, 0); for (int i = 0; i < n; i++) { scanf("%ld", &bars[i]); } vector primes; vector sieve(p, false); long start = 2; long mult = 1; while(start < p) { if (sieve[start]) { start++; continue; } primes.push_back(start); while(start*mult < p) { sieve[start*mult] = true; mult++; } start++; mult = 1; } long count = 0; for (int i = 0; i < n; i++) { count += bars[i] + breakupBar(primes, bars[i]); } cout << count << endl; }