# 14888번. 연산자 끼워넣기
importsysinput=sys.stdin.readlinedefplace(cnt,result,p,mi,mul,d):globalminAns,maxAnsifcnt==n:# 연산자 다 썼을 때
minAns=min(minAns,result)maxAns=max(maxAns,result)returnifp:place(cnt+1,result+nList[cnt],p-1,mi,mul,d)ifmi:place(cnt+1,result-nList[cnt],p,mi-1,mul,d)ifmul:place(cnt+1,result*nList[cnt],p,mi,mul-1,d)ifd:ifresult<0:place(cnt+1,-(abs(result)//nList[cnt]),p,mi,mul,d-1)else:place(cnt+1,abs(result)//nList[cnt],p,mi,mul,d-1)n=int(input())nList=list(map(int,input().split()))p,mi,mul,d=map(int,input().split())minAns=1e9+1maxAns=-1e9-1place(1,nList[0],p,mi,mul,d)print(maxAns)print(minAns)