#include <bits/stdc++.h>
using namespace std;
ifstream fin("div11.in");
ofstream fout("div11.out");
long long int n, v[100005], ans, x, f[15], b, a, Amod, Anrcif;
int nrcif(long long int a){
int cnt=0;
if(a>=0 && a<=9) return 1;
while(a>=1){
cnt++;
a/=10;
}
return cnt;
}
void solve(){
fin>>n;
for(int i=0; i<n; i++){
fin>>v[i];
x=v[i];
f[x%11]++;
}
for(int i=0; i<n; i++){
b=int(pow(10, nrcif(v[i])))%11;
a=v[i]%11;
for(int j=0; j<=10; j++){
if(((j*b)%11+a)%11==0){
ans+=f[j];
}
}
Amod=a;
Anrcif=b;
if(((Anrcif*Amod)%11+Amod)%11==0){
ans--;
}
//fout<<i<<" "<<ans<<endl;
}
fout<<ans;
}
int main(){
solve();
return 0;
}