SI-6736, SI-6747 (alternative impl.) sort out Range boundary problems

When Range contains more than Int.MaxValue elements,
it should throw IllegalArgumentException before every
meaningful operation on it. It seems that the only
reason of delaying this exception is for allowing "by"
operation.

> (Int.MinValue to 0).contains(4) # should throw exception
> (Int.MinValue to 0 by 3).contains(4) # okay

The source of all evil here is irregular use of
`numRangeElements`. It returns -1 if Range object is
invalid. Some use sites of `numRangeElements` properly check
its validity before using it, but some of them miss this
check and cause the integer overflow problems (for example,
in `lastElements`).

This commit adds missing checks.

Additionally, because they (`numRangeElements`,`lastElement`,
`terminalElement`) are completely undocumented and also have
better public alternatives (`last`,`length`), I propose to
make them private.