Program HOC24;
var i,n,t: byte;
a: array[1..100] of integer;
function tcs(x: integer): integer;
var t1: byte;
begin
t1:=0;
while x<>0 do
begin
t1:=t1+(x mod 10);
x:= x div 10;
end;
tcs:=t1;
end;
begin
write('Nhap n : ');
for i:=1 to n do
begin
write('Nhap A[',i,']='); readln(a[i]);
end;
t:=tcs(a[1]);
for i:=2 to n do if t>tcs(a[i]) then t:=max;
write(t);
readln
end.