package No400番台; import java.util.*; public class Q412 { public static void main(String[] args) { new Q412().solver(); } void solver() { Scanner sc = new Scanner(System.in); int[] demand = new int[3]; for (int i = 0; i < 3; i++) { demand[i] = sc.nextInt(); } int N = sc.nextInt(); int[] E = new int[N]; for (int i = 0; i < N; i++) { E[i] = sc.nextInt(); } long[][] dp = new long[40][5]; dp[0][0] = 1; for (int s_i = 0; s_i < N; s_i++) { for (int cond = 0; cond <= 3; cond++) { dp[s_i + 1][cond] += dp[s_i][cond]; if (cond < 3 && E[s_i] >= demand[cond]) { dp[s_i + 1][cond + 1] += dp[s_i][cond]; } else { dp[s_i + 1][cond] += dp[s_i][cond]; } } } System.out.println(dp[N][3]); } static long nCk(int n, int k) { if (n < k) return 0; else { return (fact(n) / fact(n - k) / fact(k)); } } static long fact(int n) { long ans = 1; for (int i = 1; i <= n; i++) ans *= i; return ans; } }