# what is wrong in my code?

import java.util.Scanner;
class Rupsa
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
//System.out.println("Enter umber of test cases : ");
int n = input.nextInt();
int a[][] = new int[n][];
int x,y,sum;
//System.out.println("Enter number of numbers in each test case : ");
for(int i=0;i<n;i++)
{
a[i] = new int[input.nextInt()+1];
for(int j=0;j<a[i].length;j++)
{
a[i][j] = input.nextInt();
}
}
for(int i=0;i<n;i++)
{
sum = 0;

``````				for(int j=0;j<a[i].length;j++)
{
for(int k = j+1;k<a[i].length;k++)
{
if(j<2)
{
sum = sum+(a[i][j]*a[i][k]*(int)Math.pow(2,(a[i].length-k)));
}
else
{
sum = sum+(a[i][j]*a[i][k]*(int)Math.pow(2,(a[i].length-k+1)));
}
}
}
if(a[i].length==1)
System.out.println(a[i][0]);
else
{
System.out.println(sum);
}

}
}
}``````

Overflow. Array’s length can be upto 10^5, you cant just Math.pow(2,10^5), it will cause heavy overflow.

If you are a beginner, skip this Q for now, its a easy-medium question as labelled by tag (IDK just WHO put it in beginner’s section…). It needs you to know some tricks, which you will learn during course of practicing (Easy section)problems and participating in contests.