#include <iostream>
using namespace std;
bool cifre_identice(int n)
{
int u = n % 10;
while(n)
{
if(n % 10 != u) return false;
u = n % 10;
n /= 10;
}
return true;
}
int main()
{
int n, a[10000], i, s = 0;
cin>>n;
for(i = 1; i <= n; ++i)
cin>>a[i];
for(i = 1; i ,= n; ++i)
if(cifre_identice(a[i]))
s += a[i];
cout<<s;
}