#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
#define nn '\n'
#define pi pair<ll,ll>
#define unmp unordered_map
#define uns unordered_set
#define TASK ""
ll mod = 1e9+7;
const int N = 1e5 + 5;
int MOD = 998244353;
int bit[200000];
int n;
int dem = 0;
unmp<int, int> cnt;
int daoso(int n){
string t;
while(n > 0){
int d = n % 10;
string k = to_string(d);
t += k;
n /= 10;
}
int kq = stoi(t);
return kq;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(TASK".INP","r")){
freopen(TASK".INP","r",stdin);
freopen(TASK".OUT","w",stdout);
}
cin >> n;
for(int i = 1; i <=n ; i++){
int x; cin >> x;
int target = daoso(x);
dem += cnt[target];
cnt[x]++;
}
cout << dem << nn;
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgc2Ugc2Vjb25kCiNkZWZpbmUgbm4gJ1xuJwojZGVmaW5lIHBpIHBhaXI8bGwsbGw+CiNkZWZpbmUgdW5tcCB1bm9yZGVyZWRfbWFwCiNkZWZpbmUgdW5zIHVub3JkZXJlZF9zZXQKI2RlZmluZSBUQVNLICIiCmxsIG1vZCA9IDFlOSs3Owpjb25zdCBpbnQgTiA9IDFlNSArIDU7CmludCBNT0QgPSA5OTgyNDQzNTM7CmludCBiaXRbMjAwMDAwXTsKaW50IG47CmludCBkZW0gPSAwOwp1bm1wPGludCwgaW50PiBjbnQ7CmludCBkYW9zbyhpbnQgbil7CiAgICBzdHJpbmcgdDsKICAgIHdoaWxlKG4gPiAwKXsKICAgICAgICBpbnQgZCA9IG4gJSAxMDsKICAgICAgICBzdHJpbmcgayA9IHRvX3N0cmluZyhkKTsKICAgICAgICB0ICs9IGs7CiAgICAgICAgb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