I believe you're going beyond the bounds of the array, and the program is subsequently choosing a garbage value from memory. On lines 87 and 90, you're saying the condition for the loop to execute is i <= n - 1 which means it will execute at n-1, which is the last element of the array, and then you go on the check the element to the right of that, going beyond the bounds of the array and selecting a garbage value.
Also, your logical operators are off on lines 85 and 112. It should be == instead of just one sign.