Ruby with Recursion
\nclass RLEIterator\n    def initialize(a)\n        @array = a      \n    end\n\n    def next(n)\n        return -1 if @array.empty?\n        \n        if @arra
```\nclass RLEIterator\n    def initialize(a)\n        @array = a      \n    end\n\n    def next(n)\n        return -1 if @array.empty?\n        \n        if @array[0] == n\n            value = @array[1]\n            @array = @array[2..-1]\n            value\n        elsif @array[0] > n\n            value = @array[1]\n            @array[0] -= n\n            value\n        else\n            removed = @array[0]\n            @array = @array[2..-1]\n            self.next(n-removed)\n        end\n    end\nend\n```
['Ruby']