n([],0). n([H|Tail],N):-n(Tail,0),!,((H>=0,N=0);(H<0,N=1)). n([_|Tail],N):-n(Tail,N1),N is N1+1.
?- n([1,-2,3,-4,5,-6,7],N). N = 6.