#include <iostream>
#include <cmath>
using namespace std;
int Cifre(long long nr) /// aflu cifrele fiecarui numar
{
int s = 0;
while(nr != 0)
{
s += nr % 10;
nr = nr / 10;
}
return s;
}
int main()
{
long long number, MAX = - 1 , n,save, suma, nrFinal;
cin >> n;
for(int i = 1; i <= n ; i++)
{
cin >> number;
save = number;
suma = Cifre(number);
if(suma > MAX)
{
MAX = suma;
nrFinal = save;
}
}
cout << nrFinal <<" "<< MAX;
return 0;
}