#include #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)n;++i) #define each(a,b) for(auto (a): (b)) #define all(v) (v).begin(),(v).end() #define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) #define fi first #define se second #define pb push_back #define show(x) cout<<#x<<" = "<<(x)<P; const int MAX_N = 31; ll true_pow(ll a,ll b) { ll res = 1; while(b){ if(b & 1){ res = res * a; } a = a * a; b >>= 1; } return res; } int main() { cin.tie(0); ios::sync_with_stdio(false); vector hoge(3); rep(i,3){ cin >> hoge[i]; } sort(all(hoge)); int n; cin >> n; vector u(n); rep(i,n){ cin >> u[i]; } ll c0,c1,c2,c3; c0 = c1 = c2 = c3 = 0; rep(i,n){ if(hoge[0] <= u[i]){ if(hoge[1] <= u[i]){ if(hoge[2] <= u[i]){ c3++; }else{ c2++; } }else{ c1++; } }else{ c0++; } } ll ans = 0; ans += (true_pow(2,c1) - 1)*((true_pow(2,c2)-1)*(true_pow(2,c3)-1) + (true_pow(2,c3)-c3-1)); ans += (true_pow(2,c2)-c2-1)*(true_pow(2,c3)-1) + c2*(true_pow(2,c3)-c3-1) + true_pow(2,c3)-c3*(c3-1)/2-c3-1; cout << ans * true_pow(2,c0) << endl; return 0; }