/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner s =new Scanner(System.in);
int t=s.nextInt();
while(t--!=0)
{
long n=s.nextLong();
long a=s.nextLong();
long b=s.nextLong();
long c=s.nextLong();
long ans=0,total=Long.MAX_VALUE;
for(long i=0;i<n;i++)
{
long temp=s.nextLong();
if(temp>a && temp <b || temp<a && temp >b)
{
total=Math.abs(a-b)+c;
break;
}
else if(temp>a && temp>b && a<b)
{ans=2*(temp-b)+Math.abs(a-b)+c;
if(ans<total)
total=ans;
}
else if(temp>a && temp>b && a>b)
{ans=2*(temp-a)+Math.abs(a-b)+c;
if(ans<total)
total=ans;
}
else if(temp<a && temp<b && a<b)
{ans=(2*(a-temp))+Math.abs(a-b)+c;
//System.out.println(ans);
if(ans<total)
total=ans;
}
else if(temp<a && temp<b && a>b)
{ans=(2*(b-temp))+Math.abs(a-b)+c;
//System.out.println(ans);
if(ans<total)
total=ans;
}
}
System.out.println(total);
}
}
}
I have tried all the possible test cases but still i get WA. please help me