JAVA 3-liner next()
\nclass RLEIterator {\n    int index = 0, i; \n    int[] a; \n    \n    public RLEIterator(int[] A) {\n        a = A;\n    }\n    \n    public int next(int n) {
```\nclass RLEIterator {\n    int index = 0, i; \n    int[] a; \n    \n    public RLEIterator(int[] A) {\n        a = A;\n    }\n    \n    public int next(int n) {\n        for(i = index; i < a.length && n>a[i]; n -= a[i], i+=2, index=i);\n        if(i < a.length ) a[i]-=n; \n        return i < a.length ? a[i+1] : -1; \n    }\n}\n```
[]