Why can't you just make up a look up table like [0, 2, 4, -5] and so on. Then just do a simple for loop for the various conditions such as
- adding the number from the look up table to the current value, and replacing the current value with it, or
- adding the number from the look up table to the "previous" element's value
for case #2, I'm not sure whether the result replaces the current element or the previous element.