```
var arr = '',a = [];
process.stdin.on('data',function(chunk){
arr += chunk;
});
process.stdin.on('end',function(){
arr = arr.split('\n');
let t = parseInt(arr[0]);
for(var i =1;i<=t;i++){
a[i-1]=parseInt(arr[i]);
}
let final_array = mergeSort(a);
for(var k=0;k<final_array.length;k++){
console.log(final_array[k]);
}
});
function mergeSort(a){
if(a.length === 1){
return a;
}else{
let midpoint = parseInt(a.length/2);
let left_arrr = a.slice(0,midpoint);
let right_arrr = a.slice(midpoint,a.length);
return merge(mergeSort(left_arrr),mergeSort(right_arrr));
}
}
function merge(leftArr,rightArr){
let sortedArr = [],i=0,j=0;
if((left_arr.length === 1) && (right_arr.length === 1)){
(left_arr[0] < right_arr[0])?sortedArr.push(left_arr[0],right_arr[0]):sortedArr.push(right_arr[0],left_arr[0]);
}else{
while((i<left_arr.length) && (j<right_arr.length)){
(left_arr[i] < right_arr[j])?(sortedArr.push(left_arr[i]),i++):(sortedArr.push(right_arr[j]),j++);
}
while(i<left_arr.length){
sortedArr.push(left_arr[i]);
i++;
}
while(j<right_arr.length){
sortedArr.push(right_arr[j]);
j++;
}
}
return sortedArr;
}
```

What is wrong in my code?Atleast an hint where i am wrong so that i can debug and try myself.