A = list(map(int, input().split())) A.sort() n = int(input()) E = list(map(int, input().split())) E.sort() dp = [0] * 4 dp[0] = 1 for e in E: ndp = dp[:] ndp[3] *= 2 for i in range(3): if e >= A[i]: ndp[i + 1] += dp[i] else: ndp[i] += dp[i] dp = ndp print(dp[-1])