#include #include using namespace std; const int MAX_N = 40; int demand[3], e[MAX_N]; int dp[MAX_N][5]; int main() { for (int i = 0; i < 3; i++) { cin >> demand[i]; } int n; cin >> n; for (int i = 0; i < n; i++) { cin >> e[i]; } sort(demand, demand + 3); 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]; } } } cout << dp[n][3] << endl; return 0; }