using System; using System.IO; using System.Collections; using System.Collections.Generic; using System.Text; using System.Linq; class Template { static Scanner sc; public static void Main(string[] args) { sc = new Scanner(); var vec = sc.nextIntArray(); int N = sc.nextInt(); var E = sc.nextIntArray(); int[,] dp = new int[N + 1, 4]; dp[0, 0] = 1; for (int i = 0; i < N; i++) { int cnt = 0; for (int j = 0; j < 3; j++) { if (vec[j] <= E[i]) cnt++; } dp[i + 1, 0] = dp[i, 0] * 2; for (int j = 1; j < 4; j++) { if (cnt != 0) dp[i + 1, j] = dp[i, j] + dp[i, j - 1]; else dp[i + 1, j] = dp[i, j]; } } Console.WriteLine(dp[N, 3]); } } public class Scanner { public Scanner() { } public string next() { return Console.ReadLine(); } public int nextInt() { return int.Parse(next()); } public double nextDouble() { return double.Parse(next()); } public long nextLong() { return long.Parse(next()); } public string[] nextArray() { return next().Split(' '); } public int[] nextIntArray() { return Array.ConvertAll(nextArray(), e => int.Parse(e)); } public long[] nextLongArray() { return Array.ConvertAll(nextArray(), e => long.Parse(e)); } public double[] nextDoubleArray() { return Array.ConvertAll(nextArray(), e => double.Parse(e)); } }