Simple solution
\n\n# Code\njava []\nclass Solution {\n    public long[] unmarkedSumArray(int[] nums, int[][] queries) {\n        \n        long sum = 0;\n        PriorityQueue
\n\n# Code\n```java []\nclass Solution {\n    public long[] unmarkedSumArray(int[] nums, int[][] queries) {\n        \n        long sum = 0;\n        PriorityQueue<int[]> pq = new PriorityQueue<>((a,b) -> a[0]==b[0] ? a[1]-b[1] : a[0]-b[0]);\n        for(int i=0; i<nums.length; i++){\n            sum+=nums[i];\n            pq.offer(new int[]{nums[i],i});\n        }\n\n        long[] res = new long[queries.length];\n        int qi = 0;\n        for(int[] q : queries){\n            \n            sum-=nums[q[0]];\n            nums[q[0]]=0;\n\n            while(q[1]-->0 && !pq.isEmpty()){\n                int[] num = pq.poll();\n                if(nums[num[1]]==0){\n                    q[1]++;\n                    continue;\n                }\n                sum-=num[0];\n                nums[num[1]]=0;\n            }\n\n            res[qi++]=sum;\n        }\n        return res;\n    }\n}\n```
['Java']