Ok, so if I get what you are saying correctly, I could set up a condition so that if n-1 or n-2 is less than 0, then it will default the value of x to 0?
At the same time, if n and n-1 are greater than the maximum value of the array, then the same conditions would be true?