For this Question: There is a marathon to be run on a circular track. There are N checkpoints on the track where energy drinks are placed. Checkpoints are numbered from 1 to N (both inclusive). For each checkpoint, you know the distance to the next checkpoint and also the energy replenished by the drink at this checkpoint.
Toros is going to take part in the marathon. For every 1 unit distance covered by him, his energy decreases by 1. He can't run further if he has 0 energy. Find the minimum index of the point where he should start so that he can visit every checkpoint at least once. Initially, he has 0 energy.The first line contains a single integer N, denoting the number of checkpoints.
The next N lines contain two space-separated integers, E[i] and D[i], denoting the energy replenished by the energy drink kept at the ith checkpoint and the distance to the next checkpoint.

<b>Constraints</b>
1 &le; N &le; 10<sup>5</sup>
1 &le; E[i], D[i] &le; 10<sup>9</sup>
Print a single integer containing the minimum index of the checkpoint where Toros should start so that he can complete the race.
If no such point exists, print -1Sample Input 1:
3
1 5
10 3
3 4

Sample Output 1:
2

Sample Input 2:-
3
2 4
5 4
2 7

Sample Output 2:-
-1

Sample Input 3:-
5
1 4
5 6
3 1
7 2
5 8

Sample Output 3:-
3

<b>Explanation 1:</b>
Toros starts at index 2 and drinks energy drinks. So, current energy = 10. At index 3, energy = 10 - 3 + 3 = 10. At index 1 energy = 10 - 4 + 1 = 7., I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n>10000){
            System.out.print(-1);
            return;
        }
        int[] remEnrgy = new int[n];
        for(int i=0;i<n;i++) {
            int e = sc.nextInt();
            int d = sc.nextInt();
            remEnrgy[i] = e-d;
        }
        for(int i=0;i<n;i++) {
            if(remEnrgy[i] >= 0){
                if(run(remEnrgy,i)) {
                    System.out.print(i+1);
                    return;
                }
            }
        }
        System.out.print(-1);
    }
    private static boolean run(int[]arr,int idx) {
        long enrgy = 0;
        if(idx==0){
            for(int i=0;i<arr.length-1;i++) {
                enrgy += arr[i];
                if(enrgy<0){
                    return false;
                }
            }
            return true;
        }
        for(int i=idx;i<arr.length;i++) {
            enrgy += arr[i];
            if(enrgy<0){
                return false;
            }
        }
        for(int i=0;i<idx-1;i++) {
            enrgy += arr[i];
            if(enrgy<0){
                return false;
            }
        }
        return true;
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?