class Solution:
def maxProfit(self, prices: List[int]) -> int:
total = 0
size = len(prices)
l = h = -1
i = 0
while i < size -1:
while i < size -1 and prices[i] >= prices[i+1]:
i += 1
l = prices[i]
while i < size -1 and prices[i] < prices[i+1]:
i += 1
h = prices[i]
total += h-l
return total