def max_product(arr, n):
    if n == 0:
        return 0
    
    # dp[i] stores the maximum product of increasing subsequence ending at index i
    dp = [0] * n
    
    # Initialize dp with the elements themselves
    for i in range(n):
        dp[i] = arr[i]
    
    # Fill dp table
    for i in range(1, n):
        for j in range(i):
            if arr[j] < arr[i]:
                if dp[j] * arr[i] > dp[i]:
                    dp[i] = dp[j] * arr[i]
    
    return max(dp)