MPROD-problem lunchtime

I was unable to solve this problem during the contest and after i was going through the,i found this code which is coded by @dreamoon4 who is ranked 1 in this contest but i am unable to understand his code.Can anyone explain me what does he mean from the following statement .

int tmp=max(sum[i]%2,ma[i]2-sum[i]);

i checked his result it is absolutely true but how can one arrive at such result.