Mismatch output


#1

for test case : [ 84, 2, 37, 3, 67, 82, 19, 97, 91, 63, 27, 6, 13, 90, 63, 89, 100, 60, 47, 96, 54, 26, 64, 50, 71, 16, 6, 40, 84, 93, 67, 85, 16, 22, 60 ]

when testing manually get 290
but when test button is pressed gives 333.

//code
public class Solution {

static int arr[]=new int[1000001];
public int countInversions(ArrayList<Integer> A) {
    int ret=0;
    int n = A.size();
    for(int i=n-1;i>=0;i--){
        int v = A.get(i);
        ret+=query(v-1);
        update(v,1);
    }
    return ret;
}
static void update(int x, int delta)       //add "delta" at index "x"
{
    int n = arr.length;
    for(     ; x <= n; x += x&-x)
        arr[x] += delta;
}
static int query(int x)      //returns the sum of first x elements in given array a[]
{
    int sum = 0;
    for(   ; x > 0; x -= x&-x)
        sum += arr[x];
    return sum;
}

}
//fenwick tree is used to get the prefix sum for a particular value


#2

you have to reset arr to zeros at the end of the main function body as it is a global variable.
it will be partially accepted.