Kotlin Straightforward Solution
Code
# Code
```kotlin []
class Solution {
    fun sumOfGoodNumbers(nums: IntArray, k: Int): Int {
        var sum = 0
        for (i in 0 until nums.size)
            sum += when {
                i - k < 0 -> when {
                    i + k >= nums.size -> nums[i]
                    nums[i + k] < nums[i] -> nums[i] 
                    else -> 0
                }
                i + k >= nums.size -> when {
                    i - k < 0 -> nums[i]
                    nums[i - k] < nums[i] -> nums[i]
                    else -> 0
                }
                (nums[i - k] < nums[i] && nums[i + k] < nums[i]) -> nums[i]
                else -> 0
            }
        return sum
    }
}
```
['Kotlin']