===== PascalABC.NET =====
function GetArr(n: integer) :=
ReadArrInteger('Вводите эдементы массива:', n);
function Summ(a: array of integer): integer;
begin
if a.Any(p -> p < 0) then
Result := a.TakeWhile(p -> p >= 0).Sum
else
Result := a.Sum
end;
// Тест
begin
var M := GetArr(ReadInteger('n ='));
Println(Summ(M))
end.
1. Достаточно; 2. Необходимо; 3. Достаточно.