#include using namespace std; int main() { int N; int A[200000]; long ans = 0; cin >> N; for (int i = 0;i < N;++ i) cin >> A[i]; for (int i = 0;i < N;++ i) for (int j = 0;j < N;++ j) ans += A[i] % A[j]; cout << ans << endl; }