Imagine that you need to build a transaction system. Each transaction increases, decreases, or leaves unchanged the total balance on the account. The initial balance is zero. If the result of a transaction is lower than zero, then the total balance on this account will be blocked and the returned value will be equal to the balance before the transaction.
Write a method that returns the total balance.