Multiple of 3 we

I dont understand the code works when I use d3+d4+d5+d6 instead of 20 which is same according to my understanding because the sum of pattern of 2,4,6,8 no matter how you arrange will result in 20
My wrong solution
https://www.codechef.com/viewsolution/42013933
My correct solution:
https://www.codechef.com/viewsolution/42014116