// PascalABC.NET, решение "в лоб"
begin
var n := ReadInteger('n =');
var a := ArrRandom(n, -20, 20);
a.Println;
var k := 0;
for var i := 2 to n - 2 do
if (a[i] >= a[i - 1]) and (a[i - 1] > a[i-2]) and
(a[i] > a[i+1]) then Inc(k);
Print('Количество горок:', k)
end.