#include #include const int maxn=5e5+5; int n; long long res; int a[maxn],b[maxn]; void GB(int *a,int *b,int len) { if(len<=1) return; int M=len/2,p1=0,p2=M,p=0; GB(a,b,M); GB(a+M,b+M,len-M); while(p1