Rohan is solving a very easy problem but it seems very hard to him. Actually he got a list of n numbers and he has to perform a function on those numbers which is defined as -
f(a1,a2,a3......an)=∑ni=1ai−∑n1≤i<j≤ng(ai,aj)+∑n1≤i<j<k≤ng(ai,aj,ak)−...+(−1)n−1g(a1,a2,..,an)
Rohan searches the whole internet and finds that the code to the function g(x,y) is available. Also he finds out that for more than two numbers g can be calculated as g(a,b,c)=g(g(a,b),g(b,c)) and this technique can be used to calculate g for even a list of numbers. So given a list of the numbers can you calculate the function f for Rohan . Algorithm for function g(x,y) is given below -
function g(x,y) {
if(x-y>0)
x = x^y^y; // ^ is the xor operator here
else
x = x^y^x;// ^ is the xor operator here
return x;
}
InputF(1,1) = 2 - 1 = 1