Need help writing a mechanic that will accumulate a sum of lost stamina

Oh well this was regen system, the drain system is the same thing but with a minus.