Randomized QuickSort

in randomized quicksort pivot element is chosen randomly at every recursive call?
i am using random function to do this ,
but my code is giving timelimit ,
here is my code below;-

import java.util.*;
public class Main {
static Random rand = new Random();
public static void main(String args[]) {
Scanner obj = new Scanner(System.in);
int n=obj.nextInt();
int arr[] = new int[n];
for(int i=0 ; i<arr.length ; i++)
{arr[i]=obj.nextInt();}
QuickSort(arr,0,arr.length-1);
for(int g=0 ; g<arr.length ; g++)
{System.out.print(arr[g]+" ");}
}
public static void QuickSort(int arr[] , int lo , int hi)
{if(lo>=hi)
{return;}
int pivot =lo + rand.nextInt(hi-lo+1);
int left = lo;
int right = hi;
while(left<=right)
{
while(arr[left]<arr[pivot])
{left++;}
while(arr[right]>arr[pivot])
{right–;}
if(left<=right)
{
int temp = arr[left];
arr[left] =arr[right];
arr[right] = temp;
left++;
right–;
}
QuickSort(arr,lo,right);
QuickSort(arr,left,hi);

	}
}

}

Try running the program a few more times. Assuming your piece of code works as intended, nothing can be said about the Random Quicksort. If there’s no constraints, try submitting a normal Quicksort with low/ high as pivot.