You are given an array prices where prices[i] is the price of a stock on day i. You may buy and sell as many times as you like, but you can hold at most one share at a time (you must sell before buying again). Return the maximum profit you can achieve.
Input
prices: array of non-negative integers, one per day
Output
The maximum total profit obtainable across any number of transactions.
Examples
Example 1
Inputprices = [7, 1, 5, 3, 6, 4]
Output7
Explanation: Buy at 1, sell at 5 (+4); buy at 3, sell at 6 (+3).
Example 2
Inputprices = [7, 6, 4, 3, 1]
Output0
Explanation: Prices only fall, so no profitable transaction exists.
Constraints
0 <= prices.length <= 3 * 10^4
0 <= prices[i] <= 10^4