#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
cin >> n;
int x,y,Sum=0,p=0,prod=1;
for(int i=1;i<=n;i++)
{
cin >> x;
if(x>999 and x<=9999) Sum+=x;
if(i>1)
if(x%10==y%10) p++;
if(int(sqrt(x))==sqrt(x)) prod*=x%10;
y=x;
}
cout << Sum << " " << p << " " << prod;
return 0;
}