Von nueman loves binary - help me with the correct code

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int [] arr = new int[N];
int power = 1;
int ans = 0;
for(int i=0;i<=arr.length-1;i++)
{
arr[i] = sc.nextInt();

	}
	
	while(arr[i]!=0)
	{
		int rem = arr[i] % 10;
		ans = ans + rem * power;
		//next line 
		arr[i] = arr[i] / 10;
		power = power * 2;
				
	}
	System.out.println(ans);
	arr[i]++;	
}

}

Hi @Naman_Gupta,
Here is corrected code and the correction have been commented for better understanding

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.