#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define maxn 200005
#define maxm 10000005
ll mapping[2*maxm];
ll a[maxn];
map<ll,ll> dau;
vector<ll> z;
ll n;
ll f[7]={1,11,111,1111,11111,111111,1111111};
void init(){
for(ll i=1;i<=9;i++){
for(ll j=0;j<7;j++) z.push_back(i*f[j]);
}
}
int main(){
// freopen("lala.out","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
init();
cin>>n;
ll x;
for(ll i=0;i<n;i++){
cin>>x;
a[i]=x;
mapping[x]++;
}
ll ans=0;
for (ll u=0;u<63;u++){
ll summa = z[u];
for(ll i=0;i<n;i++){
if(summa-a[i]<0) continue;
ans = ans + mapping[summa-a[i]];
if(summa-a[i]==a[i]) ans--;
}
}
ans/=2;
cout<<ans;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBsbCBsb25nIGxvbmcgCiNkZWZpbmUgbWF4biAyMDAwMDUKI2RlZmluZSBtYXhtIDEwMDAwMDA1CmxsIG1hcHBpbmdbMiptYXhtXTsKbGwgYVttYXhuXTsKbWFwPGxsLGxsPiBkYXU7CnZlY3RvcjxsbD4gejsKbGwgbjsKbGwgZls3XT17MSwxMSwxMTEsMTExMSwxMTExMSwxMTExMTEsMTExMTExMX07CnZvaWQgaW5pdCgpewogICAgZm9yKGxsIGk9MTtpPD05O2krKyl7CiAgICAgICBmb3IobGwgaj0wO2o8NztqKyspIHoucHVzaF9iYWNrKGkqZltqXSk7CiAgIH0KfQppbnQgbWFpbigpewogICAgLy8gZnJlb3BlbigibGFsYS5vdXQiLCJ3IixzdGRvdXQpOwogICAgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CiAgICBjaW4udGllKE5VTEwpOwogICBpbml0KCk7CiAgICBjaW4+Pm47CiAgICBsbCB4OwogICAgZm9yKGxsIGk9MDtpPG47aSsrKXsKICAgICAgICBjaW4+Png7CiAgICAgICAgYVtpXT14OwogICAgICAgIG1hcHBpbmdbeF0rKzsKICAgIH0KICAgIGxsIGFucz0wOwogICAgZm9yIChsbCB1PTA7dTw2Mzt1KyspewogICAgICAgICAgIGxsIHN1bW1hID0gelt1XTsKICAgICAgICBmb3IobGwgaT0wO2k8bjtpKyspewogICAgICAgICAgICBpZihzdW1tYS1hW2ldPDApIGNvbnRpbnVlOwogICAgICAgICAgICBhbnMgPSBhbnMgKyBtYXBwaW5nW3N1bW1hLWFbaV1dOwogICAgICAgICAgICBpZihzdW1tYS1hW2ldPT1hW2ldKSBhbnMtLTsKICAgICAgICB9CiAgICB9CiAgICBhbnMvPTI7CiAgICBjb3V0PDxhbnM7CiAgICAKICAgcmV0dXJuIDA7Cn0=