Java program for the above approach
import java . io . * ; class GFG { static int INF64 = ( int ) 1e10 ; static int N = 200 * 1000 + 13 ; static int n ; static int arr [ ] = new int [ N ] ; static int brr [ ] = new int [ N ] ;