B,C,D=sorted(map(int,input().split())) N=int(input()) A=list(map(int,input().split())) A.sort() DP=[1,0,0,0] for a in A: NDP=DP[:] if a>=B: NDP[1]+=DP[0] else: NDP[0]+=DP[0] if a>=C: NDP[2]+=DP[1] else: NDP[1]+=DP[1] if a>=D: NDP[3]+=DP[2] else: NDP[2]+=DP[2] NDP[3]+=DP[3] DP=NDP print(DP[-1])