Minimum Scalar Product in Java