Runtime Exception on a test

Ok, so now here is the tricky question, i am trying to pass a task on the platform, and one of the tests keeps failing because of runtime exception. Unfortunately i don’t know the exact input, the condition indicates that input has at least two numbers and that the answer is unambiguous. The task is to find two numbers in the list with highest multiplication result. Can anyone help? I am exhausted

fun main() { val a = readLine()?.split(" ")?.map{it.toLong()}?:listOf(0.toLong(), 0.toLong()) fun findTwoNumbersWithHighestMultiplicationResult(a: List<Long>) { val sorted = a.sorted() if (sorted[0] * sorted[1] > sorted[sorted.size-1] * sorted[sorted.size-2]) print(sorted[0].toString() + " " + sorted[1].toString()) else print(sorted[sorted.size-2].toString() + " " + sorted[sorted.size1].toString()) } findTwoNumbersWithHighestMultiplicationResult(a) } 

submitted by /u/space_trueper
[link] [comments]