#include <bits/stdc++.h>
#define int long long
#define MAX 1000000
#define deb(x) cout << #x << "=" << x << endl;
using namespace std;
vector<int> phi(MAX + 5);
signed main() {
phi[1] = 1;
int i,j;
for( i=0;i<MAX;i++)phi[i]=i;
for( i=2;i<MAX;i++){
if(phi[i]==i){
for(j=i;j<MAX;j+=i){
phi[j]-=phi[j]/i;
}
}
}
int sum = 0;
for (int i = 1; i <= MAX; i++) {
sum += phi[i];
phi[i] = sum;
phi[i] = (2LL * phi[i]) - 1;
}
long long q, ans = 0;
cin >> q;
while (q--) {
int n;
cin >> n;
int temp = phi[n];
ans += temp;
}
cout << ans;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CiNkZWZpbmUgaW50IGxvbmcgbG9uZwojZGVmaW5lIE1BWCAxMDAwMDAwCiNkZWZpbmUgZGViKHgpIGNvdXQgPDwgI3ggPDwgIj0iIDw8IHggPDwgZW5kbDsKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnZlY3RvcjxpbnQ+IHBoaShNQVggKyA1KTsKCnNpZ25lZCBtYWluKCkgewogICAgcGhpWzFdID0gMTsKICAgIGludCBpLGo7CiAgICBmb3IoIGk9MDtpPE1BWDtpKyspcGhpW2ldPWk7CiAgICBmb3IoIGk9MjtpPE1BWDtpKyspewogICAgICAgIGlmKHBoaVtpXT09aSl7CiAgICAgICAgICAgIGZvcihqPWk7ajxNQVg7ais9aSl7CiAgICAgICAgICAgICAgICBwaGlbal0tPXBoaVtqXS9pOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgICAgIGludCBzdW0gPSAwOwogICAgZm9yIChpbnQgaSA9IDE7IGkgPD0gTUFYOyBpKyspIHsKICAgICAgICBzdW0gKz0gcGhpW2ldOwogICAgICAgIHBoaVtpXSA9IHN1bTsKICAgICAgICBwaGlbaV0gPSAoMkxMICogcGhpW2ldKSAtIDE7CiAgICB9CiAgICBsb25nIGxvbmcgcSwgYW5zID0gMDsKICAgIGNpbiA+PiBxOwogICAgd2hpbGUgKHEtLSkgewogICAgICAgIGludCBuOwogICAgICAgIGNpbiA+PiBuOwogICAgICAgIGludCB0ZW1wID0gcGhpW25dOwogICAgICAgIGFucyArPSB0ZW1wOwogICAgfQogICAgY291dCA8PCBhbnM7CgogICAgcmV0dXJuIDA7Cn0=