Help me in solving ATM2 problem

My issue

I am getting runtime error please solve it

My code

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

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

	}
}

Problem Link: ATM Machine Practice Coding Problem

The runtime error in your code is likely due to an ArrayIndexOutOfBoundsException caused by accessing arr[i+1] when i is the last index of the array. Specifically, in the line:

if (l > arr[i+1])