#!/usr/bin/env python3 import bisect import collections def solve(bcd, es): def p2(x): return 1 << x reqs = sorted(bcd) s = collections.Counter(bisect.bisect(reqs, e) for e in es) res = (p2(s[1]) - 1) * (p2(s[2]) - 1) * (p2(s[3]) - 1) res += (p2(s[1]) - 1) * (p2(s[3]) - 1 - s[3]) res += (p2(s[2]) - 1 - s[2]) * (p2(s[3]) - 1) res += s[2] * (p2(s[3]) - 1 - s[3]) res += p2(s[3]) - 1 - s[3] - s[3] * (s[3] - 1) // 2 res *= p2(s[0]) return res def main(): bcd = (int(x) for x in input().split()) _ = input() es = (int(x) for x in input().split()) print(solve(bcd, es)) if __name__ == '__main__': main()