AC记录
#include <iostream>
using namespace std;
typedef long long ll;
const ll MAXN=1e7+5;
ll n,cnt,top,xorl,xorr;
ll stack[MAXN];
struct node{
ll data,lson,rson;
node(){
data=lson=rson=0;
}
} a[MAXN];
inline int read(){
ll x=0,f=1;
char ch=getchar();
while( ch<'0' || ch>'9' ){
if( ch=='-' )
f=-1;
ch=getchar();
}
while( ch>='0' && ch<='9' ){
x=x*10+ch-48;
ch=getchar();
}
return x*f;
}
inline void build(){
ll temp=top;
while( top && a[stack[top]].data>=a[cnt].data )
top--;
if( top )
a[stack[top]].rson=cnt;
if( top<temp )
a[cnt].lson=stack[top+1];
stack[++top]=cnt;
}
int main() {
n=read();
for(ll i=1;i<=n;i++){
++cnt;
a[cnt].data=read();
build();
}
for(ll i=1;i<=n;i++){
xorl^=i*(a[i].lson+1);
xorr^=i*(a[i].rson+1);
}
printf("%lld %lld",xorl,xorr);
return 0;
}