Salary is the problem code pls someone see loop hole and text

import java.io.;
import java.util.
;
class minimumnumbersofmove
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t,n,a[],i;
t=sc.nextInt();
for(i=0;i<t;i++)
{
n=sc.nextInt();
a=new int[n];
for(int j=0;j<n;j++)
{
a[j]=sc.nextInt();
}
Arrays.sort(a);
if(a[n-1]-a[0]==0)
System.out.println(a[n-1]-a[0]);
else
System.out.println((a[n-1]-a[0])+1);
}
}
}