#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(int i=(a);i<(b);++i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define MOD 1000000007 int main(){ int rs[3]; cin>>rs[0]>>rs[1]>>rs[2]; int n; cin>>n; vector v; rep(i,0,n){ int a; cin>>a; v.pb(a); } sort(all(v)); int d[33]; clr(d,0); rep(i,0,v.sz){ rep(j,0,3){ if(v[i]>=rs[j]){ d[i]++; } } } int dp[33][4]; clr(dp,0); dp[0][0] = 1; rep(i,1,v.sz+1){ rep(j,0,4){ if(d[i-1]==j){ dp[i][j] += dp[i-1][j]*2; } else if(d[i-1]>j){ dp[i][j] += dp[i-1][j]; dp[i][j+1] += dp[i-1][j]; } } } cout << dp[v.sz][3] << endl; return 0; }