Doubt regarding problem NMN03 of contest ISPC

I tried to solve the problem NMN03 of ISPC and on failing looked at successful submissions. I was really suprised to see them. Can anybody please tell me how to solve it and why is the ans always 0. Is there a point I am missing. link:Problem

Here is why

The problem would have been a nightmare if the upper limit of N was declared in the order of 10^5 or 10^6. Personally, I tried the O(N^2) approach until this question struck in my mind.