#include using namespace std; int dp[101][1<<3]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); vector x(3); for (int i = 0; i < 3; i++) cin >> x[i]; int n; cin >> n; vector y(n); for (int i = 0; i < n; i++) cin >> y[i]; dp[0][0] = 1; for (int i = 0; i < n; i++) { for (int j = 0; j < 1<<3; j++) { int jt = j; for (int k = 0; k < 3; k++) { if (!(j & 1 << k) && y[i] >= x[k]) { jt |= 1 << k; break; } } dp[i+1][j] += dp[i][j]; dp[i+1][jt] += dp[i][j]; } } cout << dp[n][0b111] << endl; return 0; }