One loop solution (javascript) - 56ms
\nvar RLEIterator = function(A) {\n    this.nums = A;\n    this.currentIndex = 0;\n};\n\n/** \n * @param {number} n\n * @return {number}\n */\nRLEIterator.proto
```\nvar RLEIterator = function(A) {\n    this.nums = A;\n    this.currentIndex = 0;\n};\n\n/** \n * @param {number} n\n * @return {number}\n */\nRLEIterator.prototype.next = function(n) {\n    for (var i = this.currentIndex; i < this.nums.length; i += 2) {\n        if (this.nums[i] >= n) {\n            this.nums[i] -= n;\n            return this.nums[i + 1];\n        } else {\n            n -= this.nums[i];\n            this.currentIndex += 2;\n        }\n    }\n    \n    return -1;\n};\n```
[]