Why do my code is failing the hidden input test cases? : This is the problem to be solved:

John is assigned a new task today. He is given an array A containing N integers. His task is to update all elements of array to some minimum value x , that is, **A[i]=x;1<=i<=N** ;

such that sum of this new array is strictly greater than the sum of the initial array. Note that x should be as minimum as possible such that sum of the new array is greater than the sum of the initial array.

**Input Format:**
First line of input consists of an integer N denoting the number of elements in the array A.
Second line consists of N space separated integers denoting the array elements.

**Output Format:**
The only line of output consists of the value of x. 

**Sample Input:** 

5

12345

**Sample Output:**
4
**Explanation:**

Initial sum of array=1+2+3+4+5=15

When we update all elements to 4, sum of array = 4+4+4+4+4=20 which is greater than 15.
Note that if we had updated the array elements to 3,sum=15 which is not greater than 15. So, 4 is the minimum value to which array elements need to be updated.

**==> Here is my code. How can I improve it? or What is the problem in this code?**

        import java.util.Scanner;
    
    public class Test2 {
        public static void main(String []args){
            Scanner s=new Scanner(System.in);
            int check=0, sum=0, biggest=0;
            int size=s.nextInt();
    
            if(size>=1 && size<=100000) {
                int[] arr=new int[size];
                for(int i=0; i<size; i++){
                    int temp=s.nextInt();
                    if(temp>=1 && temp<=1000) {
                        arr[i] = temp;
                        biggest=biggest > temp ? biggest:temp;
                        sum=sum+temp;
                    }
                    else break;
                }
                for(int i=1; i<biggest; i++){
                    check=(size*i)>sum ? i:0;
    
                }
                System.out.print(check);
    
            }
            else System.err.print("Invalid input size");
    
    
        }
    }

