#include <stdio.h>

int n, b, c, d, e[100];
int x, y, z;

void swap(int &x, int &y) {
	int temp = x;
	x = y;
	y = temp;
	
	return;
}

int main() {
	scanf("%d%d%d%d", &b, &c, &d, &n);
	for(int i = 0; i < n; i++) { scanf("%d", &e[i]); }
	
	if(c > d) { swap(c, d); }
	if(b > c) { swap(b, c); }
	if(c > d) { swap(c, d); }
	for(int i = 0; i < n; i++) {
		     if(d <= e[i]) { z++; }
		else if(c <= e[i]) { y++; }
		else if(b <= e[i]) { x++; }
	}
	
	int ans = (1 << n) - (1 << (n - z)) - (1 << (n - z - y)) * z - (1 << (n - z - y - x)) * (z * (z - 1) / 2 + z * y);
	printf("%d\n", ans);
	
	return 0;
}