Compile and run gives expected output but during submission it says nzec error and runtime error

/*
Problem
Chef is given two arrays AA and BB of length NN each.

In one operation Chef can choose one element of AA and one element of BB and increase them by 11.

More formally: Chef can pick two integers i, ji,j (1\le i, j \le N)(1≤i,j≤N) and increment A_iA 
i
​
  and B_jB 
j
​
  by 11.

Determine the minimum number of operations required to make AA and BB equal.

Output -1−1 if it is not possible to make AA and BB equal.
*/
import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
    int CR(int a, int b, int count) {
		a+=1;
		count++;
		if(a==b) {
			return count;
		}else {
			return CR(a, b, count);
		}
	}    
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Codechef obj = new Codechef();
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		while(t-- > 0){
		    int n = sc.nextInt();
            int ACount = 0;
            int BCount = 0;
		    int[] arr1 = new int[n];
		    int[] arr2 = new int[n];
		    
		    for(int i=0; i<arr1.length; i++){
		        arr1[i] = sc.nextInt();
		    }
		    for(int i=0; i<arr2.length; i++){
		        arr2[i] = sc.nextInt();
		    }
		    for(int i=0; i<arr1.length; i++) {
    	    	if(arr1[i]<arr2[i]) {
    	    		ACount = ACount + obj.CR(arr1[i], arr2[i], 0);
    	    	}else {
    	    		BCount = BCount + obj.CR(arr2[i], arr1[i], 0);
    	    	}
	         }
    	    if(ACount == BCount) {
    	    	System.out.println(ACount);
    	    }else {
    	    	System.out.println(-1);
    	    }
		}
	}
}