*n*canbe very large. For now, you can asume

*n*<= 1000. Note that, for the same problem in 2D, I can think of a solution in

*O(n)*. Just take the vector summation of

*b1, b2 .. bn*where

*bi*is the perpendicular normal vector to

*ai*having the same length as

*ai*.