#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 1e6 + 5;
unordered_map<int, int> D;
int sumDigit(int n){
int sum = 0;
while(n!=0){
sum += n%10;
n/=10;
}
return sum;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, x;
cin>>n;
for(int i=1;i<=n;++i){
cin>>x;
D[sumDigit(x)]++;
}
int res = 0;
for(auto it:D){
if(it.second > 1){
res += it.second * (it.second - 1) / 2;
}
}
cout<<res;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSB1bGwgdW5zaWduZWQgbG9uZyBsb25nCiNkZWZpbmUgbGwgbG9uZyBsb25nCiNkZWZpbmUgYWxsKHgpIHguYmVnaW4oKSwgeC5lbmQoKQp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgbWF4biA9IDFlNiArIDU7CnVub3JkZXJlZF9tYXA8aW50LCBpbnQ+IEQ7CmludCBzdW1EaWdpdChpbnQgbil7CiAgICBpbnQgc3VtID0gMDsKICAgIHdoaWxlKG4hPTApewogICAgICAgIHN1bSArPSBuJTEwOwogICAgICAgIG4vPTEwOwogICAgfQogICAgcmV0dXJuIHN1bTsKfQppbnQgbWFpbigpIHsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7IGNpbi50aWUoMCk7IGNvdXQudGllKDApOwogICAgaW50IG4sIHg7CiAgICBjaW4+Pm47CiAgICBmb3IoaW50IGk9MTtpPD1uOysraSl7CiAgICAgICAgY2luPj54OwogICAgICAgIERbc3VtRGlnaXQoeCldKys7CiAgICB9CiAgICBpbnQgcmVzID0gMDsKICAgIGZvcihhdXRvIGl0OkQpewogICAgICAgIGlmKGl0LnNlY29uZCA+IDEpewogICAgICAgICAgICByZXMgKz0gaXQuc2Vjb25kICogKGl0LnNlY29uZCAtIDEpIC8gMjsKICAgICAgICB9CiAgICB9CiAgICBjb3V0PDxyZXM7Cn0KCg==