import times, strutils, sequtils, math, algorithm, tables, sets, lists, intsets import critbits, future, strformat, deques template `max=`(x,y) = x = max(x,y) template `min=`(x,y) = x = min(x,y) template `mod=`(x,y) = x = x mod y template scan2 = (scan(), scan()) template scan3 = (scan(), scan()) let read* = iterator: string {.closure.} = while true: (for s in stdin.readLine.split: yield s) proc scan(): int = read().parseInt proc scanf(): float = read().parseFloat proc toInt(c:char): int = return int(c) - int('0') proc solve()= var n = scan() a = newseqwith(n,scan()) res = -int.high.div(4) proc dfs(idx:int,val:int)= if idx==n: res.max=val else: var tmax = -int.high.div(4) tmin=int.high.div(4) tmax.max=val*a[idx] tmin.min=val*a[idx] tmax.max=val+a[idx] tmin.min=val+a[idx] tmax.max=val-a[idx] tmin.min=val-a[idx] if a[idx]!=0: tmax.max=val div a[idx] tmin.min=val div a[idx] dfs(idx+1,tmax) dfs(idx+1,tmin) dfs(1,a[0]) echo res solve()