Sgn(tanx)=Sgn(sinx)⋅Sgn(cosx) and that Sgn(cotx)=Sgn(cosx)⋅Sgn(sinx), it follows that Sgn(tanx)=Sgn(cotx).
Introducing the variables a=Sgn(sinx)=±1 and b=Sgn(cosx)=±1 allows us to express the function as f(x)=a+b+2ab.
In Quadrant I where a=1 and b=1, f=4; in Quadrant II where a=1 and b=−1, f=−2;
in Quadrant III where a=−1 and b=−1, f=0; and in Quadrant IV where a=−1 and b=1, f=−2.
Thus the range of f is {−2,0,4} and the sum of these values is −2+0+4=2