It changes sign everywhere cos(nx) vanishes, when nx is an odd multiple of pi/2. You might find it easier to count if you do the change of variables u=nx first. Then follow tnutty's advice and add up the positive parts and negative parts separately. Try and guess the answer first. For large n you get many cosine cycles. So it ought to be the integral from 0 to pi/2 of x*(the average value of |cos|).How do I know where it becomes negative?