You're only adding up the current element and the immediate previous element of observations. Instead, you should be taking the current element of observations and adding that to the previous element...