#include <bits/stdc++.h>
using namespace std;
#define SC scanf
#define PF printf
#define ull unsigned long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define sort_a(a) sort(a.begin(),a.end());
#define sort_d(a) sort(a.rbegin(),a.rend());
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define rev(s) reverse(s.begin(),s.end())
#define P(ok) cout << (ok ? "YES\n": "NO\n")
#define __Heart__ ios_base :: sync_with_stdio(false); cin.tie(NULL);
#define ll long long
typedef pair< ll , ll> PII;
const int sz = 1e6 ;
vector<vector<ll>> dp(sz + 1);
ll lcmOfaAndb(ll a , ll b) {
ll gc = __gcd(a , b) ;
ll prod = a * b ;
ll lc = prod / gc ;
return lc ;
}
void PreCalc() {
for(ll a = 2 ; a <= sz ; a++) {
unordered_set<int> st;
for(ll k = 1 ; k * a <= sz ; k++){
ll b = lcmOfaAndb(k , a) - a ;
if (b >= a && b <= sz && (a * b) % (a + b) == 0) st.insert(b) ;
}
for(auto it : st) dp[a].pb(it) ;
}
}
void solve()
{
ll n , Ans = 0; cin >> n ; ll a[n] ;
map < int , int > freq ;
for(auto &x : a) cin >> x , freq[x]++ ;
for(int i = 0 ; i < n ; i++){
for(auto it : dp[a[i]]) {
Ans += freq[it] ;
if(it == a[i]) Ans-- ;
}
}
cout << Ans << "\n" ;
}
int main()
{
__Heart__
PreCalc() ;
int t ; t = 1; while(t--) solve() ;
}