Solving the N-body problem in (2+1) gravity