title: Python - how to add and subtract elements in array
body: <p>If I have an array, let's say: <code>np.array([4,8,-2,9,6,0,3,-6])</code> and I would like to add the previous number to the next element, how do I do? 
  And every time the number 0 shows up the addition of elements 'restarts'.</p>
  
  <p>An example with the above array, I should get the following output when I run the function:</p>
  
  <p><code>stock = np.array([4,12,10,19,25,0,3,-3])</code> is the right output, if the above array is inserted in transactions.</p>
  
  <pre><code>def cumulativeStock(transactions):
  
      # insert your code here
  
      return stock
  </code></pre>
  
  <p>I can't think of a method to solving this problem. Any help would be very appreciated.</p>