assume the A is blue, it scan from bottom to up for all the rest N-1 point. count=1 +1 for blue point -1 for red point. So, there are 499 times +1 and 500 times -1. count will reach 0 at some point. The point that makes count = 0 is the B. the worse case is the B is the last one. then all N-2 points are in the one side and 0 point in the other side.