heres the link for the question "Divan and a new Project" [](https://codeforces.me/contest/1614/problem/B)
Why wont this solution work? It prints the correct minimum time taken and also prints the coordinates properly. But when i submit it shows error on the first testcase and says — "wrong answer answer is wrong: pans = 14 is not equal real_pans = 18 (test case 1)" i dont get this. the answer to the first example is 14 why is it saying its 18?
import java.util.*;
public class divan {
public static void main(String[]args){
java.util.Scanner sc=new java.util.Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++){
int n=sc.nextInt();
int []arr=new int[n];
for(int j=0;j<n;j++)arr[j]=sc.nextInt();
Arrays.sort(arr);
boolean negative=true;
int neg=-1;
int pos=1;
boolean positive=false;
int time=0;
int []ans=new int[n+1];
ans[0]=0;
int idx=1;
for(int j=n-1;j>=0;j--){
if(negative){
int now=2*Math.abs(0-neg)*arr[j];
ans[idx]=neg;
idx++;
time+=now;
positive=true;
negative=false;
}
else{
int now=2*Math.abs(0-pos)*arr[j];
ans[idx]=pos;
idx++;
time+=now;
positive=false;
negative=true;
neg--;
pos++;
}
}
System.out.println(time);
for(int j=0;j<ans.length;j++)System.out.print(ans[j] + " ");
System.out.println();
}
sc.close();
}
}