def compute_op(a, b, op):
    if op == '+':
        return a + b
    elif op == '-':
        return a - b
    elif op == '*':
        return a * b
    elif op == '/':
        if b == 0:
            return None
        # Compute division with truncation towards zero
        q = a // b
        # If the signs are different and there's a remainder, adjust the quotient
        if (a ^ b) < 0 and a % b != 0:
            q += 1
        return q
    else:
        return None

def main():
    import sys
    input = sys.stdin.read().split()
    N = int(input[0])
    a = list(map(int, input[1:N+1]))
    
    if N == 0:
        print(0)
        return
    
    current_max = a[0]
    current_min = a[0]
    
    for i in range(N-1):
        next_num = a[i+1]
        candidates = []
        for op in ['+', '-', '*', '/']:
            if op == '/' and next_num == 0:
                continue
            for val in [current_max, current_min]:
                res = compute_op(val, next_num, op)
                if res is not None:
                    candidates.append(res)
        if not candidates:
            print(0)
            return
        
        current_max = max(candidates)
        current_min = min(candidates)
    
    print(current_max)

if __name__ == '__main__':
    main()