Skip to main content
2 of 2
added 129 characters in body
rm -rf
  • 89.3k
  • 21
  • 297
  • 480

Here is another way:

With[{acc = Accumulate@data}, acc[[;; -#]] ~Join~ data[[-# + 1 ;;]] &@Count[acc, _?Positive]]
(* {-1050, -1000, 1, 1950, 1950, 1950, 525, 0} *)

You can also use Tr@Boole@Thread[acc > 0]] instead of Count[...] or if you want ≥0, then you can use Tr@UnitStep[acc].

rm -rf
  • 89.3k
  • 21
  • 297
  • 480