fork download
  1. n = int(input())
  2. zyski = [int(input()) for i in range(n)]
  3.  
  4. maks_zysk = 0
  5. biezaca_suma = 0
  6.  
  7. for zysk in zyski:
  8. biezaca_suma += zysk
  9. if biezaca_suma < 0:
  10. biezaca_suma = 0
  11. maks_zysk = max(maks_zysk, biezaca_suma)
  12.  
  13. print(maks_zysk)
  14.  
Success #stdin #stdout 0.04s 9788KB
stdin
5
1 
-2
4
5
-2
stdout
9