I've finished your code: [login to view URL]
It shows the correct answer 144 for the case where:
n = 8
x = [1,4,2,3,5]
y = [4,7,6,5,8]
I'll clean up the code quick and send it over immediately if you choose my bid. But it's getting late over here so it might be tomorrow.