实在搞不懂哪里不对,那就丢讨论区看看有没有大佬吧:(
#include <bits/stdc++.h>
#define __init ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define int long long
using namespace std;
int n, m, ans;
unordered_map<int, int> f;
signed main() {
__init;
int tmp;
cin >> n;
while(n--) {
cin >> tmp;
f[tmp]++, m = max(m, tmp);
}
for(pair<int, int> i:f) {
for(int j = 2*i.first;j <= m;j+=i.first)
ans += i.second * f[j];
ans += i.second * (i.second-1);
}
cout << ans;
return 0;
}