What is the error in my code for Rupsa and the Game problem

import java.io.*;

import java.util.*;

public class Rupsa

{

 public static void main(String args[])throws IOException
{
    int T=0,i,j,count=0,l,k,N[],N1=0,pts=0,res[],sum=0,m,arr[];
    double a = Math.pow(10,5);
    double b = Math.pow(10,9);
    double c = b + 7;
    boolean flag1,flag2,flag3;
    String str;
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);
    Scanner sc = new Scanner(System.in);
    T = Integer.parseInt(br.readLine());
    flag1 = T>=1 && T<=10;
    if(flag1==false)
    {
       do
       {
          System.out.println("Please enter the value of T greater than 1 and less than equal to 10");
          T = Integer.parseInt(br.readLine());
       }while(!flag1);
    }
    N = new int[T];
    res = new int[T];
        for(i=0;i<T;i++)
        {
            sum = 0;
            N[i] = Integer.parseInt(br.readLine());
            flag2 = N[i]>=1 && N[i]<=(int)a;
            if(flag2 == false)
            {
               do
               {
                  System.out.println("Please enter the value of N greater than 1 and less than equal to 10^5");
                  N[i] = Integer.parseInt(br.readLine());
               }while(!flag2);
            }
            N1 = N[i] + 1;
            StringTokenizer st = new StringTokenizer(br.readLine());
            arr = new int[N1];
            for(j=0;j<N1;j++)
            {
                arr[j] = Integer.parseInt(st.nextToken());
                flag3 = arr[j]>=1 && arr[j]<=(int)b;
                if(flag3 == false)
                {
                    do
                    {
                        System.out.println("Please enter the value of Ai greater than 1 and less than 10^9");
                        arr[j] = Integer.parseInt(st.nextToken());
                    }while(!flag3);
                }
            }
            if(N1<=3)
            {
               pts = arr[0]*arr[1];
               sum = sum + pts;
               sum = sum * 2;
               for(m=2;m<N1;m++)
               {
                   for(k=m-1;k>=0;k--)
                   {
                       pts = arr[m]*arr[k];
                       sum = sum + pts;
                   }    
                   sum = sum * 2;
               }
               System.out.println(sum);
               res[i] = sum%(int)c;
            }
            else
            {
                pts = arr[0];
                k = 1;
                for(m=1;m<N1;m++)
                {
                    sum = 2*((arr[m]*pts) + sum);
                    pts = (pts + k*arr[m]);
                    k = k*2;
                }
                System.out.println(sum);
                res[i] = sum%(int)c;
            }
        }
    }
    
}

Try explaining your approach instead of putting the complete code, this will help us understand better.Otherwise helping you in your queries takes a lot of time(just a suggestion).