public ArrayList<Integer> subarraySumClosest(int[] nums) {
        // write your code here
        ArrayList<Integer> ans = new ArrayList<Integer>();
        if (nums == null || nums.length == 0)
            return ans;
        if (nums.length == 1) {
            ans.add(0);
            ans.add(0);
            return ans;
        }
        Pair[] sum = new Pair[nums.length + 1];
        int prev = 0;
        for (int i = 1; i <= nums.length; ++i) {
            sum[i] = new Pair(prev + nums[i], i);
            prev += nums[i];
        }
        Arrays.sort(sum, new Comparator<Pair>() {
            public int compare(Pair a, Pair b) {
                return a.sum - b.sum;
            }
        });
        for (Pair p : sum) {
            Printer.println(p.sum + " " + p.index);
        }
        int min = Integer.MAX_VALUE;
        for (int i = 1; i < nums.length; ++i) {
            if (min > sum[i].sum - sum[i - 1].sum) {
                min = sum[i].sum - sum[i - 1].sum;
                int[] temp = {sum[i].index, sum[i - 1].index};
                Arrays.sort(temp);
                ans.clear();
                ans.add(temp[0]);
                ans.add(temp[1]);
            }
        }
        return ans;
    }