C ++ program for the above approach .
#include <bits/stdc++.h> NEW_LINE using namespace std ; const long long INF64 = 1000000000000000000ll ; const int N = 200 * 1000 + 13 ; int n ; long long arr [ N ] , brr [ N ] ;