//PascalABC.NET
var
A: array [1..15] of integer;
i, sum, n: integer;
begin
for i := 1 to 15 do
begin
A[i] := random(1001)-500;
write(A[i], ' ');
end;
writeln;
for i := 2 to 14 do
if ((A[i] > A[i - 1]) and (A[i] > A[i + 1])) then
begin
sum := 0;
n := A[i];
while ( n<>0 ) do
begin
sum := sum + (n mod 10);
n := n div 10;
if n in [-9 .. -1] then
begin
if sum - abs(n) < 0 then
sum := abs(sum) - abs(n)
else
sum := sum - abs(n);
break;
end;
end;
writeln('Сумма цифр числа ', A[i], ' = ', sum);
end;
end.