def solve(self, cipher):
        """
        Buy one, sell many

        dp: get the largest from right
        f[i] = max(a_i, f[i+1])
        :param cipher: the cipher
        """
        N, A = cipher
        f = [0 for _ in A]
        f[N - 1] = A[N - 1]
        for i in xrange(N - 2, -1, -1):
            f[i] = max(A[i], f[i + 1])

        profit = 0
        for i in xrange(N - 1):
            profit += max(0, A[i] - f[i + 1])

        return profit
dataset/ETHPy150Open algorhythms/HackerRankAlgorithms/Stock Maximize.py/Solution.solve/swapped operands of `-`