Suitable pairs#745

Suitable pairs

1 second
128 megabytes
Medium (≈1350)

We call a pair of non-negative integers suitable if there is at least one common digit in their decimal notation (not necessarily in the same digit). Let there be given n non-negative numbers a[1], a[2], ..., a[n]. Consider all possible pairs (a[i], a[j]) (1 ≤ i < j ≤ n).

Write a program that will determine the number of all suitable pairs.

Input

The first line contains positive integer n, not greater than 10^6. Second line contains n nonnegative integers, not greater 999.

Output

Print the number of suitable pairs.

Examples

Example 1

Loading
Loading

Example 2

Loading
Loading