#include<bits/stdc++.h>usingnamespace std;#defineullunsignedlonglong
ull sd =111111111111111111ull, sd2, k =1;
ull qu, n, ans;//qu表示每次询问的位置。
inline ull get_q(inti){
sd =(sd2 ^(sd2 >>3))+998244353;return((sd2 = sd ^(sd <<37))& k)+((i &1)?0:(n - k -1));}int q, q2;voidinit(){//Put your code here or not.
}inline ull get_ans(ull x){//Put your code here.
}intmain(){
cin >> n;
sd2 = n;while((k <<1)<= n +1) k <<=1;
k -=1;
cin >> q >> q2;init();for(int i =1; i <= q; i++){
cin >> qu;
ans +=get_ans(qu)* i;}for(int i =1; i <= q2; i++){
qu =get_q(i);
ans +=get_ans(qu)*(i + q);}
cout << ans << endl;return0;}