i = N-1
j = i+1 = N-1 +1 = N --- for (... j < N... ): condition false, so "N-1" is not the last iteration for inner loop
i = N-2
j = i+1 = N-2 +1 = N-1 --- for (... j < N ...): condition true, this is the last iteration. But it writes to a[N-1][N-1].