Book allocation problem solution issue

I’ve solved the problem without using binary search and getting correct results when checked but when I submit it here, all the test cases are failing.
Can you check my code and let me know what’s wrong with it?

package Pratice2;
import java.util.Scanner;

public class five {

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int testCase = sc.nextInt();
	for (int i = 0; i < testCase; i++) {
		int len = sc.nextInt();
		int stu = sc.nextInt();
		long arr[] = new long[len];
		long arraySum = 0;
		long arraySumTwo = 0;
		long ans = 0;
		for (int j = 0; j < len; j++) {
			long arrVal = sc.nextInt();
			arr[j] = arrVal;
		}
		for (int j = 0; j < arr.length; j++) {
			arraySum = arraySum +arr[j];
		}
		long avg = arraySum/stu;
		for (int j = 0; j < arr.length; j++) {
			arraySumTwo = arraySumTwo +arr[j];
			if(arraySumTwo > avg) {
				if(ans < arraySumTwo ) {
					ans = arraySumTwo;	
				}
					arraySumTwo = 0;
			}
		}
		System.out.println(ans);
	}
}

}

Hey @patnamsainikhil Test Case like :
1
4 2
12 34 67 90 is failing by your code.Answer Should be 157 but your code is giving 113.

Thank you for your response.

But the answer is 113.
1st students : 12 , 34, 67 (total = 113)
2nd students : 90 (total = 90)

So the answer is 113, it’s the same shown on the question page.

Hey @patnamsainikhil Very sorry for my mistake I just copied the wrong input.
1
6 3
12 34 55 67 90 95 .For this input, your code is giving output 185 but it should be 157.

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.