import itertools X = sorted(list(map(int, input().split()))) N = int(input()) E = sorted(list(map(int, input().split()))) ans = 0 for t in itertools.combinations(range(N), 3): if all(E[t[i]] >= X[i] for i in range(3)): ans += 2 ** t[0] print(ans)