I see you edited some more, now really fixing that uninteresting off-by-one error. But it still doesn't work, as the main error is still there. It works until n = 5 (not "N", btw) but fails for n = 6 and higher. Submitting it would've shown that to you.
Can you fix it? Maybe it's possible, but I don't see how. Can't find the mistake in your reasoning if I don't know your reasoning.