Help me in solving PREFPRO2 problem

My issue

we fi

My code

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;

class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	Scanner sc=new Scanner(System.in);
	int n=sc.nextInt();
	int[] arr=new int[n+1];
	for(int i=1;i<=n;i++)
	{
	    arr[i]=sc.nextInt();
	}
	for(int i=2;i<=n;i++)
	{
	    arr[i]=arr[i]+arr[i-1];
	}
	int k=sc.nextInt();
	while(k-- >0)
	{
	    int a=sc.nextInt();
	      int b=sc.nextInt();
	      if(a == 0)
	      {
	        System.out.println(arr[b]);   
	      }
	     
	      else{
	          System.out.println(arr[b]-arr[a-1]); 
	      }
	      
	}

	}
}

Learning course: Prefix sums
Problem Link: Optimization Using Prefix Array Practice Problem in Prefix sums - CodeChef

You are overflowing your array “arr” when you sum up all the elements.

According to the contraints, you can have up to 100,000 elements of up to 100,000 value. Then there’s a chance that the last element be 10,000,000,000 (10^10) when you sum them all, which overflows an integer that can only store a number up to 2,147,483,647 (2*10^9)

You should use long type instead of int