#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <time.h>
#include <utility>

int Bin(int n, int k) {
    double res = 1;
    for (int i = 1; i <= k; ++i)
        res = res*(n-k+i)/i;
    return (int) (res + 0.01);
}

int main() {
    std::ios_base::sync_with_stdio(false);
    int g, d, f;
    int64_t counter = 0;
    std::cin >> g >> d >> f;
    std::vector<std::pair<int, int>>  vec(g+d+f);
    int tmp_num;
    int tmp = 0;
    int gl = 0, df = 0, fw = 0;

    for (int i = 0; i < g; ++i) {
        std::cin >> tmp_num;
        vec[i] = std::pair<int, int>(tmp_num, 1);
    }

    for (int i = 0; i < d; ++i) {
        std::cin >> tmp_num;
        vec[i + g] = std::pair<int, int>(tmp_num, 2);
    }

    for (int i = 0; i < f; ++i) {
        std::cin >> tmp_num;
        vec[i + g + d] = std::pair<int, int>(tmp_num, 3);
    }
    std::sort(vec.begin(), vec.end());

    std::vector<int> answer(g+d+f);

    for (int j = 0; j < 5; ++j) {
        if (vec[j].first >= (vec[5].first + 1)/2) {
            tmp = j;
            break;
        }
    }

    for (int j = tmp; j < 5; ++j) {
        if (vec[j].second == 1) ++gl;
        if (vec[j].second == 2) ++df;
        if (vec[j].second == 3) ++fw;
    }

    for (int i = 5; i < answer.size(); ++i) {
        if (vec[i].second == 1) {
            ++gl;
        };
        if (vec[i].second == 2){
            ++df;
        };
        if (vec[i].second == 3){
            ++fw;
        };
        while (vec[tmp].first < (vec[i].first + 1)/2) {
            if (vec[tmp].second == 1) {
                gl -= 1;
            }
            if (vec[tmp].second == 2) {
                df -= 1;
            }
            if (vec[tmp].second == 3) {
                fw -= 1;
            }
            ++tmp;
        }
        if (vec[i].second == 1) {
            answer[i] = answer[i-1] + (Bin(df, 2) * Bin(fw, 3));
        } else if (vec[i].second == 2) {
            answer[i] = answer[i-1] + (gl * Bin(fw, 3) *(Bin(df, 2) - Bin(df - 1, 2)));
        } else if (vec[i].second == 3) {
            answer[i] = answer[i-1] + (gl * Bin(df, 2) *(Bin(fw, 3) - Bin(fw-1, 3)));
        }
    }
    //std::cout << float(clock() - t1)/CLOCKS_PER_SEC << "\n";
    std::cout << answer[answer.size()-1] << std::endl;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main() {
    int g, d, f;
    int64_t counter = 0;
    std::cin >> g >> d >> f;
    std::vector<int>  goal(g);
    std::vector<int>  def(d);
    std::vector<int>  frw(f);
    int max_1,max_2,max_3,max_4,max_5,min_1,min_2,min_3,min_4,min_5;

    for (int i = 0; i < g; ++i) {
        std::cin >> goal[i];
    }

    for (int i = 0; i < d; ++i) {
        std::cin >> def[i];
    }

    for (int i = 0; i < f; ++i) {
        std::cin >> frw[i];
    }

    for (int i = 0; i < g; ++i) {
        for (int o = 0; o < d-1; ++o) {
            min_1 = std::min(goal[i], def[o]);
            max_1 = std::max(goal[i], def[o]);
            if (min_1 * 2 < max_1)
                continue;
            for (int p = o + 1; p < d; ++p) {
                min_2 = std::min(min_1, def[p]);
                max_2 = std::max(max_1, def[p]);
                if (min_2 * 2 < max_2) {
                    continue;
                }
                for (int z = 0; z < f-2; ++z) {
                    min_3 = std::min(min_2, frw[z]);
                    max_3 = std::max(max_2, frw[z]);
                    if (min_3 * 2 < max_3) {
                        continue;
                    }
                    for (int x = z + 1; x < f-1; ++x) {
                        min_4 = std::min(min_3, frw[x]);
                        max_4 = std::max(max_3, frw[x]);
                        if (min_4 * 2 < max_4) {
                            continue;
                        }
                        for (int c = x + 1; c < f; ++c) {
                            min_5 = std::min(min_4, frw[c]);
                            max_5 = std::max(max_4, frw[c]);
                            if (min_5*2 >= max_5){
                                ++counter;
                            }
                        }
                    }
                }
            }
        }
    }

    std::cout << counter << std::endl;

}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

bool check(int min_4, int max_4, int frw) {
    return ((min_4 >= frw && 2*frw >= max_4) || (min_4 <= frw && max_4 >= frw) || (frw >= max_4 && 2*min_4 >= frw));
}

int main() {
    int g, d, f;
    int64_t counter = 0;
    std::cin >> g >> d >> f;
    std::vector<int>  goal(g);
    std::vector<int>  def(d);
    std::vector<int>  frw(f);
    int max_1,max_2,max_3,max_4,max_5,min_1,min_2,min_3,min_4;

    for (int i = 0; i < g; ++i) {
        std::cin >> goal[i];
    }

    for (int i = 0; i < d; ++i) {
        std::cin >> def[i];
    }

    for (int i = 0; i < f; ++i) {
        std::cin >> frw[i];
    }

    std::sort(goal.begin(), goal.end());
    std::sort(def.begin(), def.end());
    std::sort(frw.begin(), frw.end());

    for (int i = 0; i < g; ++i) {
        for (int o = 0; o < d-1; ++o) {
            if (def[o] > goal[i] && def[o] > 2*goal[i]) {
                break;
            }
            if (def[o] < goal[i] && goal[i] > 2*def[o]) {
                continue;
            }
            min_1 = std::min(goal[i], def[o]);
            max_1 = std::max(goal[i], def[o]);
            for (int p = o + 1; p < d; ++p) {
                if (def[p] > min_1 && def[p] > 2*min_1) {
                    break;
                }
                if (!check(min_1, max_1, def[p])) {
                    continue;
                }
                min_2 = std::min(min_1, def[p]);
                max_2 = std::max(max_1, def[p]);
                for (int z = 0; z < f-2; ++z) {
                    if (frw[z] > min_2 && frw[z] > 2*min_2) {
                        break;
                    }
                    if (!check(min_2, max_2, frw[z])) {
                        continue;
                    }
                    min_3 = std::min(min_2, frw[z]);
                    max_3 = std::max(max_2, frw[z]);
                    for (int x = z + 1; x < f-1; ++x) {
                        if (frw[x] > min_3 && frw[x] > 2*min_3) {
                            break;
                        }
                        if (!check(min_3, max_3, frw[x])) {
                            continue;
                        }
                        min_4 = std::min(min_3, frw[x]);
                        max_4 = std::max(max_3, frw[x]);
                        for (int c = x + 1; c < f; ++c) {
                            if (check(min_4, max_4, frw[c])) {
                                ++counter;
                            }
                        }
                    }
                }
            }
        }
    }

    std::cout << counter << std::endl;

}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
typedef long long ll;

inline pair<bool,int> count(const vector<int> &v, int xmin, int xmax) {
	auto l = lower_bound(v.begin(), v.end(), xmin);
	auto u = upper_bound(l, v.end(), xmax);
	return make_pair(*l == xmin, distance(l, u));
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifdef DEBUG
	ifstream file("in.txt");
	cin.rdbuf(file.rdbuf());
#endif

	int ng, nd, nf;
	cin >> ng >> nd >> nf;
	vector<int> g(ng), d(nd), f(nf);
	for (int i = 0; i < ng; ++i) {
		cin >> g[i];
	}
	for (int i = 0; i < nd; ++i) {
		cin >> d[i];
	}
	for (int i = 0; i < nf; ++i) {
		cin >> f[i];
	}

	sort(g.begin(), g.end());
	sort(d.begin(), d.end());
	sort(f.begin(), f.end());

	vector<int> all;
	all.reserve(g.size() + d.size() + f.size());

	all.insert(all.end(), g.begin(), g.end());
	all.insert(all.end(), d.begin(), d.end());
	all.insert(all.end(), f.begin(), f.end());
	sort(all.begin(), all.end());

	ll ret = 0;
	for (auto x : all) {
		bool bg, bd, bf;
		ll cg, cd, cf;
		tie(bg, cg) = count(g, x, 2*x);
		tie(bd, cd) = count(d, x, 2*x);
		tie(bf, cf) = count(f, x, 2*x);
		if (bg) {
			ret += cd*(cd-1) / 2 * cf*(cf-1)*(cf-2) / 6;
		} else if (bd) {
			ret += cg * (cd-1) * cf*(cf-1)*(cf-2) / 6;
		} else if (bf) {
			ret += cg * cd*(cd-1) / 2 * (cf-1)*(cf-2) / 2;
		} else {
			return -1;
		}
	}
	cout << ret << endl;

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main () {
  long long g, d, f;
  cin >> g >> d >> f;
  vector<pair<long long, long long>> all;
  for (int i = 0; i < g; ++i) {
    int cur;
    cin >> cur;
    all.emplace_back(cur, 0);
  }
  for (int i = 0; i < d; ++i) {
    int cur;
    cin >> cur;
    all.emplace_back(cur, 1);
  }
  for (int i = 0; i < f; ++i) {
    int cur;
    cin >> cur;
    all.emplace_back(cur, 2);
  }
  sort(all.begin(), all.end());

  long long count = 0;
  long long n = g + d + f;
  for (int i = 0; i < n; ++i) {
    long long twice = all[i].first * 2;
    long long c1 = 0, c2 = 0, c3 = 0;
    for (int j = i + 1; j < n; ++j) {
      if (all[j].first > twice)
        break;
      if (all[j].second == 0)
        ++c1;
      else if (all[j].second == 1)
        ++c2;
      else
        ++c3;
    }
    if (all[i].second == 0) {
      if (c2 < 2 || c3 < 3)
        continue;
      count += c2 * (c2 - 1) / 2 * c3 * (c3 - 1) * (c3 - 2) / 6;
    } else if (all[i].second == 1) {
      if (c1 < 1 || c2 < 1 || c3 < 3)
        continue;
      count += c1 * c2 * c3 * (c3 - 1) * (c3 - 2) / 6;
    } else {
      if (c1 < 1 || c2 < 2 || c3 < 2)
        continue;
      count += c1 * c2 * (c2 - 1) / 2 * c3 * (c3 - 1) / 2;
    }
  }

  cout << count << endl;
}


#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int maxn = 1005;
const int maxk = 2e5+5;

int ga[maxn], da[maxn], fa[maxn];
vector<pair<int, int> > all;
int pga[maxk], pda[maxk], pfa[maxk];

long long c_fun2(long long n) {
    return n * (n - 1) / 2;
}

long long c_fun3(long long n) {
    return n * (n - 1) * (n - 2) / 6;
}

int main() {
    int g, d, f;

    cin >> g >> d >> f;

    for (int i = 0; i < g; i++) {
        cin >> ga[i];
        all.push_back(make_pair(ga[i], 0));
        pga[ga[i]] = 1;
    }
    for (int i = 0; i < d; i++) {
        cin >> da[i];
        all.push_back(make_pair(da[i], 1));
        pda[da[i]] = 1;
    }
    for (int i = 0; i < f; i++) {
        cin >> fa[i];
        all.push_back(make_pair(fa[i], 2));
        pfa[fa[i]] = 1;
    }

    pga[0] = 0;
    pda[0] = 0;
    pfa[0] = 0;

    for (int i = 1; i < maxk; i++) {
        pga[i] = pga[i] + pga[i - 1];
        pda[i] = pda[i] + pda[i - 1];
        pfa[i] = pfa[i] + pfa[i - 1];
    }

    sort(all.begin(), all.end());

    long long ans = 0;

    for (int i = 0; i < all.size(); i++) {
        int from = all[i].first;
        int to = from * 2;

        long long gcount = pga[to] - pga[from];
        long long dcount = pda[to] - pda[from];
        long long fcount = pfa[to] - pfa[from];

        if (all[i].second == 0) {
            ans += c_fun2(dcount) * c_fun3(fcount);
        }
        if (all[i].second == 1) {
            ans += gcount * dcount * c_fun3(fcount);
        }
        if (all[i].second == 2) {
            ans += gcount * c_fun2(dcount) * c_fun2(fcount);
        }
    }

    cout << ans << endl;
}


#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int maxn = 1005;
const int maxk = 1e5+5;

int ga[maxn], da[maxn], fa[maxn];
vector<pair<int, int> > all;
int pga[maxk], pda[maxk], pfa[maxk];

long long c_fun2(long long n) {
    return n * (n - 1) / 2;
}

long long c_fun3(long long n) {
    return n * (n - 1) * (n - 2) / 6;
}

int main() {
    int g, d, f;

    cin >> g >> d >> f;

    for (int i = 0; i < g; i++) {
        cin >> ga[i];
        all.push_back(make_pair(ga[i], 0));
        pga[ga[i]] = 1;
    }
    for (int i = 0; i < d; i++) {
        cin >> da[i];
        all.push_back(make_pair(da[i], 1));
        pda[da[i]] = 1;
    }
    for (int i = 0; i < f; i++) {
        cin >> fa[i];
        all.push_back(make_pair(fa[i], 2));
        pfa[fa[i]] = 1;
    }

    pga[0] = 0;
    pda[0] = 0;
    pfa[0] = 0;

    for (int i = 1; i < maxk; i++) {
        pga[i] = pga[i] + pga[i - 1];
        pda[i] = pda[i] + pda[i - 1];
        pfa[i] = pfa[i] + pfa[i - 1];
    }

    sort(all.begin(), all.end());

    long long ans = 0;

    for (int i = 0; i < all.size(); i++) {
        int from = all[i].first;
        int to = from * 2;

        long long gcount = pga[to] - pga[from];
        long long dcount = pda[to] - pda[from];
        long long fcount = pfa[to] - pfa[from];

        if (all[i].second == 0) {
            ans += c_fun2(dcount) * c_fun3(fcount);
        }
        if (all[i].second == 1) {
            ans += gcount * dcount * c_fun3(fcount);
        }
        if (all[i].second == 2) {
            ans += gcount * c_fun2(dcount) * c_fun2(fcount);
        }
    }

    cout << ans << endl;
}


#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int maxn = 1005;
const int maxk = 1e5+5;

int ga[maxn], da[maxn], fa[maxn];
vector<pair<int, int> > all;
int pga[maxk], pda[maxk], pfa[maxk];

long long c_fun2(long long n) {
    return n * (n - 1) / 2;
}

long long c_fun3(long long n) {
    return n * (n - 1) * (n - 2) / 6;
}

int main() {
    int g, d, f;

    cin >> g >> d >> f;

    for (int i = 0; i < g; i++) {
        cin >> ga[i];
        all.push_back(make_pair(ga[i], 0));
        pga[ga[i]] = 1;
    }
    for (int i = 0; i < d; i++) {
        cin >> da[i];
        all.push_back(make_pair(da[i], 1));
        pda[da[i]] = 1;
    }
    for (int i = 0; i < f; i++) {
        cin >> fa[i];
        all.push_back(make_pair(fa[i], 2));
        pfa[fa[i]] = 1;
    }

    for (int i = 0; i < maxk; i++) {
        pga[i] = pga[i] + pga[i - 1];
        pda[i] = pda[i] + pda[i - 1];
        pfa[i] = pfa[i] + pfa[i - 1];
    }

    sort(all.begin(), all.end());

    long long ans = 0;

    for (int i = 0; i < all.size(); i++) {
        int from = all[i].first;
        int to = from * 2;

        long long gcount = pga[to] - pga[from];
        long long dcount = pda[to] - pda[from];
        long long fcount = pfa[to] - pfa[from];

        if (all[i].second == 0) {
            ans += c_fun2(dcount) * c_fun3(fcount);
        }
        if (all[i].second == 1) {
            ans += gcount * dcount * c_fun3(fcount);
        }
        if (all[i].second == 2) {
            ans += gcount * c_fun2(dcount) * c_fun2(fcount);
        }
    }

    cout << ans << endl;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

bool cmp(pair<int, char> &p1, pair<int, char> &p2)
{
	if (p1.first <= p2.first) return true;
	return false;
}

int main()
{
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	int g, d, f, n;
	cin >> g >> d >> f;
	n = g + d + f;
	vector< pair<int, char> > players;
	/*
	g - goalkeeper
	d - defender
	f - forward
	*/
	//creating of the array
	int num;
	for (int i = 0; i < g; i++) {
		cin >> num;
		players.push_back(make_pair(num, 'g'));
	}
	for (int i = 0; i < d; i++) {
		cin >> num;
		players.push_back(make_pair(num, 'd'));
	}
	for (int i = 0; i < f; i++) {
		cin >> num;
		players.push_back(make_pair(num, 'f'));
	}

	sort(players.begin(), players.end(), cmp);

	//Counting frame & ans
	int next = 0, prev = 0;
	long long gn, dn, fn, ans;
	long long ag, ad, af;
	gn = dn = fn = ans = 0;
	do {
		//relaxation of the frame
		while (next < n && players[next].first <= players[prev].first * 2) {
			switch (players[next].second) {
			case 'g':
				gn++; break;
			case 'd':
				dn++; break;
			case 'f':
				fn++; break;
			}
			next++;
		}

		if (gn < 1 || dn < 2 || fn < 3) {
			switch (players[prev].second) {
			case 'g':
			{
				gn--;
				break;
			}
			case 'd':
			{
				dn--;
				break;
			}
			case 'f':
			{
				fn--;
				break;
			}
			}
			prev++;
			continue;
		}
		//counting
		ag = ad = af = 1;
		switch (players[prev].second) {
		case 'g':
		{
			ad = (dn * (dn - 1)) / 2;
			af = (fn * (fn - 1) * (fn - 2)) / 6;
			break;
		}
		case 'd':
		{
			ag = gn;
			ad = (dn - 1);
			af = (fn * (fn - 1) * (fn - 2)) / 6;
			break;
		}
		case 'f':
		{
			ag = gn;
			ad = (dn * (dn - 1)) / 2;
			af = ((fn - 1) * (fn - 2)) / 2;
			break;
		}
		}
		//ans upd
		ans += ag * ad * af;
		switch (players[prev].second) {
		case 'g':
		{
			gn--;
			break;
		}
		case 'd':
		{
			dn--;
			break;
		}
		case 'f':
		{
			fn--;
			break;
		}
		}
		prev++;
	} while (prev < n);

	cout << ans;
	return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

bool cmp(pair<int, char> &p1, pair<int, char> &p2)
{
	if (p1.first <= p2.first) return true;
	return false;
}

int main()
{
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	int g, d, f, n;
	cin >> g >> d >> f;
	n = g + d + f;
	vector< pair<int, char> > players;
	/*
	g - goalkeeper
	d - defender
	f - forward
	*/
	//creating of the array
	int num;
	for (int i = 0; i < g; i++) {
		cin >> num;
		players.push_back(make_pair(num, 'g'));
	}
	for (int i = 0; i < d; i++) {
		cin >> num;
		players.push_back(make_pair(num, 'd'));
	}
	for (int i = 0; i < f; i++) {
		cin >> num;
		players.push_back(make_pair(num, 'f'));
	}

	sort(players.begin(), players.end(), cmp);

	//Counting frame & ans
	int next = 0, prev = 0;
	long long gn, dn, fn, ans;
	long long ag, ad, af;
	gn = dn = fn = ans = 0;
	do {
		//relaxation of the frame
		while (next < n && players[next].first <= players[prev].first * 2) {
			switch (players[next].second) {
			case 'g':
				gn++; break;
			case 'd':
				dn++; break;
			case 'f':
				fn++; break;
			}
			next++;
		}

		if (gn < 1 || dn < 2 || fn < 3) {
			prev++;
			continue;
		}
		//counting
		ag = ad = af = 1;
		switch (players[prev].second) {
		case 'g':
		{
			ad = (dn * (dn - 1)) / 2;
			af = (fn * (fn - 1) * (fn - 2)) / 6;
			break;
		}
		case 'd':
		{
			ag = gn;
			ad = (dn - 1);
			af = (fn * (fn - 1) * (fn - 2)) / 6;
			break;
		}
		case 'f':
		{
			ag = gn;
			ad = (dn * (dn - 1)) / 2;
			af = ((fn - 1) * (fn - 2)) / 2;
			break;
		}
		}
		//ans upd
		ans += ag * ad * af;
		switch (players[prev].second) {
		case 'g':
		{
			gn--;
			break;
		}
		case 'd':
		{
			dn--;
			break;
		}
		case 'f':
		{
			fn--;
			break;
		}
		}
		prev++;
	} while (prev < n);

	cout << ans;
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;
const int mn = 500005;
vector<pair<int, int> > a;

ll ff(ll aa, ll bb, ll cc) {
    if ((aa >= 1) && (bb >= 2) && (cc >= 3)) {
        return aa * bb * (bb - 1) / 2 * cc * (cc - 1) * (cc - 2) / 6;
    }
    return 0;
}

ll cnt[3], pcnt[3];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int g, d, f;
    cin >> g >> d >> f;
    for (int i = 0; i < g; i++) {
        int x;
        cin >> x;
        a.pb({x, 0});
    }
    for (int i = 0; i < d; i++) {
        int x;
        cin >> x;
        a.pb({x, 1});
    }
    for (int i = 0; i < f; i++) {
        int x;
        cin >> x;
        a.pb({x, 2});
    }
    int n = a.size();
    sort(a.begin(), a.end());
    int r = 0;
    ll ans = 0;
    for (int l = 0; l < n; l++) {
        r = max(l, r);
        while ((r < n) && (a[r].fi <= 2 * a[l].fi)) {
            cnt[a[r].se]++;
            r++;
        }
        ans += ff(cnt[0], cnt[1], cnt[2]);
        if (l != 0) {
            ans -= ff(pcnt[0], pcnt[1], pcnt[2]);
        }
        cnt[a[l].se]--;
        for (int j = 0; j < 3; j++) {
            pcnt[j] = cnt[j];
        }
    }
    cout << ans;
    return 0;
}


#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

int get(int num, int need) {
    if (need == 0) {
        return 1;
    }
    int a = 1, b = 1;
    for (int i = 0; i != need; ++i) {
        a *= (num-i);
        b *= (i+1);
    }
    return a/b;
}

int main() {
    int g, d, f, number;
    cin >> g >> d >> f;
    vector<int> players;
    unordered_map<int, int> type;
    for (int i = 0; i != g; ++i) {
        cin >> number;
        players.push_back(number);
        type[number] = 0;
    }
    for (int i = 0; i != d; ++i) {
        cin >> number;
        players.push_back(number);
        type[number] = 1;
    }
    for (int i = 0; i != f; ++i) {
        cin >> number;
        players.push_back(number);
        type[number] = 2;
    }
    sort(players.begin(), players.end());
    vector<vector<int> > sum(3, vector<int>(g+d+f, 0));
    for (int i = 0; i != g+d+f; ++i) {
        if (i != 0) {
            sum[0][i] = sum[0][i-1];
            sum[1][i] = sum[1][i-1];
            sum[2][i] = sum[2][i-1];
        }
        ++sum[type[players[i]]][i];
    }
    vector<int> need(3);
    int n = g+d+f, ans = 0;
    for (int i = 0; i != n; ++i) {
        for (int j = i+5; j < n && players[j] <= 2*players[i]; ++j) {
            need[0] = 1;
            need[1] = 2;
            need[2] = 3;
            if (type[players[i]] == type[players[j]] &&
                type[players[i]] == 0) {
                continue;
            }
            --need[type[players[i]]];
            --need[type[players[j]]];
            g = sum[0][j-1] - sum[0][i];
            d = sum[1][j-1] - sum[1][i];
            f = sum[2][j-1] - sum[2][i];
            if (g < need[0] || d < need[1] || f < need[2]) {
                continue;
            }
            ans += get(g, need[0])*get(d, need[1])*get(f, need[2]);
        }
    }
    cout << ans;
    return 0;
}


#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

long long get(int num, int need) {
    if (need == 0) {
        return 1;
    }
    long long a = 1, b = 1;
    for (int i = 0; i != need; ++i) {
        a *= (num-i);
        b *= (i+1);
    }
    return a/b;
}

int main() {
    int g, d, f, number;
    cin >> g >> d >> f;
    vector<int> players;
    unordered_map<int, int> type;
    for (int i = 0; i != g; ++i) {
        cin >> number;
        players.push_back(number);
        type[number] = 0;
    }
    for (int i = 0; i != d; ++i) {
        cin >> number;
        players.push_back(number);
        type[number] = 1;
    }
    for (int i = 0; i != f; ++i) {
        cin >> number;
        players.push_back(number);
        type[number] = 2;
    }
    sort(players.begin(), players.end());
    vector<vector<int> > sum(3, vector<int>(g+d+f, 0));
    for (int i = 0; i != g+d+f; ++i) {
        if (i != 0) {
            sum[0][i] = sum[0][i-1];
            sum[1][i] = sum[1][i-1];
            sum[2][i] = sum[2][i-1];
        }
        ++sum[type[players[i]]][i];
    }
    vector<int> need(3);
    int n = g+d+f;
    long long ans = 0;
    for (int i = 0; i != n; ++i) {
        for (int j = i+5; j < n && players[j] <= 2*players[i]; ++j) {
            need[0] = 1;
            need[1] = 2;
            need[2] = 3;
            if (type[players[i]] == type[players[j]] &&
                type[players[i]] == 0) {
                continue;
            }
            --need[type[players[i]]];
            --need[type[players[j]]];
            g = sum[0][j-1] - sum[0][i];
            d = sum[1][j-1] - sum[1][i];
            f = sum[2][j-1] - sum[2][i];
            if (g < need[0] || d < need[1] || f < need[2]) {
                continue;
            }
            ans += get(g, need[0])*get(d, need[1])*get(f, need[2]);
        }
    }
    cout << ans;
    return 0;
}


//  file: codeforces1
# include <bits/stdc++.h>

using namespace std;

void checkTime(){printf("\n%f seconds", (double)(clock()) / CLOCKS_PER_SEC);}

const double PI = 3.1415926535897932384626433832795;
const int mod = 1e9 + 7;
const int inf = 5e8 + 100;
const int N = 2e5 + 10;
const int M =  1e5 + 10;

int C(int n, int k)
{
	int ans = 1;
	for (int i = n; i > n - k; i--)ans *= i;
	for (int i = 1; i <= k; i++)ans /= i;
	return ans;
}

int g, d, f;
int gs[M], ds[M], fs[M];
int sl[3010];
long long ans;

void solve()
{
	cin >> g >> d >> f;
	for (int i = 1; i <= g; i++){
		cin >> sl[i];
		gs[sl[i]]++;
	}

	for (int i = 1; i <= d; i++){
		cin >> sl[i + g];
		ds[sl[i + g]]++;
	}

	for (int i = 1; i <= f; i++){
		cin >> sl[i + g + d];
		fs[sl[i + g + d]]++;
	}

	for (int i = 1; i < M; i++){
		gs[i] += gs[i - 1];
		ds[i] += ds[i - 1];
		fs[i] += fs[i - 1];
	}

	for (int i = 1; i <= g + d + f; i++){
		int s = sl[i];
		int cnt1 = gs[2 * s] - gs[s - 1];
		int cnt2 = ds[2 * s] - ds[s - 1];
		int cnt3 = fs[2 * s] - fs[s - 1];
		ans += C(cnt1, 1) * 1ll * C(cnt2, 2) * 1ll * C(cnt3, 3);
	}
	cout << ans;
}

int main()
{
	int TE = 1;
	//freopen("square.in", "r", stdin);
	//freopen("square.out", "w", stdout);
	//cin >> TE;
	while(TE--)
		solve();

	//checkTime();
	return 0;
}


//  file: codeforces1
# include <bits/stdc++.h>

using namespace std;

void checkTime(){printf("\n%f seconds", (double)(clock()) / CLOCKS_PER_SEC);}

const double PI = 3.1415926535897932384626433832795;
const int mod = 1e9 + 7;
const int inf = 5e8 + 100;
const int N = 2e5 + 10;
const int M =  1e5 + 10;

int C(int n, int k)
{
	int ans = 1;
	for (int i = n; i > n - k; i--)ans *= i;
	for (int i = 1; i <= k; i++)ans /= i;
	return ans;
}

int g, d, f;
int gs[M], ds[M], fs[M];
int sl[3010];
long long ans;

void solve()
{
	cin >> g >> d >> f;
	for (int i = 1; i <= g; i++){
		cin >> sl[i];
		gs[sl[i]]++;
	}

	for (int i = 1; i <= d; i++){
		cin >> sl[i + g];
		ds[sl[i + g]]++;
	}

	for (int i = 1; i <= f; i++){
		cin >> sl[i + g + d];
		fs[sl[i + g + d]]++;
	}

	for (int i = 1; i < M; i++){
		gs[i] += gs[i - 1];
		ds[i] += ds[i - 1];
		fs[i] += fs[i - 1];
	}

	for (int i = 1; i <= g + d + f; i++){
		int s = sl[i];
		int cnt1 = gs[2 * s] - gs[s - 1];
		int cnt2 = ds[2 * s] - ds[s - 1];
		int cnt3 = fs[2 * s] - fs[s - 1];
		//cout << s << ' ' << cnt1 << ' ' << cnt2 << ' ' << cnt3 << ' ';
		if(i <= g){
			ans += C(cnt1 - 1, 0) * 1ll * C(cnt2, 2) * 1ll * C(cnt3, 3);
		}
		else if(i <= g + d){
			ans += C(cnt1, 1) * 1ll * C(cnt2 - 1, 1) * 1ll * C(cnt3, 3);
		}
		else if(i <= g + d + f){
			ans += C(cnt1, 1) * 1ll * C(cnt2, 2) * 1ll * C(cnt3 - 1, 2);
		}
		//cout << ans << endl;
	}
	cout << ans;
}

int main()
{
	int TE = 1;
	//freopen("square.in", "r", stdin);
	//freopen("square.out", "w", stdout);
	//cin >> TE;
	while(TE--)
		solve();

	//checkTime();
	return 0;
}


//  file: codeforces1
# include <bits/stdc++.h>

using namespace std;

void checkTime(){printf("\n%f seconds", (double)(clock()) / CLOCKS_PER_SEC);}

const double PI = 3.1415926535897932384626433832795;
const int mod = 1e9 + 7;
const int inf = 5e8 + 100;
const int N = 2e5 + 10;
const int M =  1e5 + 10;

long long C(int n, int k)
{
	long long  ret = 1;
	for (int i = n; i > n - k; i--)ret *= i;
	for (int i = 1; i <= k; i++)ret /= i;
	return ret;
}

int g, d, f;
int gs[N], ds[N], fs[N];
int sl[4010];
long long ans;

void solve()
{
	cin >> g >> d >> f;
	for (int i = 1; i <= g; i++){
		cin >> sl[i];
		gs[sl[i]]++;
	}

	for (int i = 1; i <= d; i++){
		cin >> sl[i + g];
		ds[sl[i + g]]++;
	}

	for (int i = 1; i <= f; i++){
		cin >> sl[i + g + d];
		fs[sl[i + g + d]]++;
	}

	for (int i = 1; i < N; i++){
		gs[i] += gs[i - 1];
		ds[i] += ds[i - 1];
		fs[i] += fs[i - 1];
	}

	for (int i = 1; i <= g + d + f; i++){
		int s = sl[i];
		int cnt1 = gs[2 * s] - gs[s - 1];
		int cnt2 = ds[2 * s] - ds[s - 1];
		int cnt3 = fs[2 * s] - fs[s - 1];
		//cout << s << ' ' << cnt1 << ' ' << cnt2 << ' ' << cnt3 << ' ';
		if(i <= g){
			ans += C(cnt1 - 1, 0) * 1ll * C(cnt2, 2) * 1ll * C(cnt3, 3);
		}
		else if(i <= g + d){
			ans += C(cnt1, 1) * 1ll * C(cnt2 - 1, 1) * 1ll * C(cnt3, 3);
		}
		else if(i <= g + d + f){
			ans += C(cnt1, 1) * 1ll * C(cnt2, 2) * 1ll * C(cnt3 - 1, 2);
		}
		//cout << ans << endl;
	}
	cout << ans;
}

int main()
{
	int TE = 1;
	//freopen("square.in", "r", stdin);
	//freopen("square.out", "w", stdout);
	//cin >> TE;
	while(TE--)
		solve();

	//checkTime();
	return 0;
}


#include <bits/stdc++.h>
#define elif else if
using namespace std;

typedef unsigned long long ull;
typedef long long ll;

const ll MAXN = 2e5 + 5, INF = 9e13, MOD = 1e9 + 7;

ll n, k, ans, gd[MAXN], dd[MAXN], fd[MAXN], gk, dk, fk, g[MAXN], d[MAXN], f[MAXN], m, mi, ma;

int main()
{
    /*ios::sync_with_stdio(0);
    cin.tie(0);*/
    cin >> gk >> dk >> fk;

    for(int i = 0; i < gk; i++)
    {
        cin >> g[i];
        gd[g[i]] = 1;
    }
    sort(g, g + gk);

    for(int i = 0; i < dk; i++)
    {
        cin >> d[i];
        dd[d[i]] = 1;
    }
    sort(d, d + dk);

    for(int i = 0; i < fk; i++)
    {
        cin >> f[i];
        fd[f[i]] = 1;
    }
    sort(f, f + fk);

    for(ll i = 1; i < MAXN; i++)
        fd[i] += fd[i - 1];
    for(ll i = 1; i < MAXN; i++)
        dd[i] += dd[i - 1];
    for(ll i = 1; i < MAXN; i++)
        gd[i] += gd[i - 1];

    //GMIN
    for(int i = 0; i < gk; i++)
    {
        ll kek = 1;
        mi = g[i];
        ma = g[i] * 2;

        m = dd[ma] - dd[mi];
        kek *= m * (m - 1) / 2;

        m = fd[ma] - fd[mi];
        kek *= m * (m - 1) * (m - 2) / 6;

        ans += kek;
    }
    //DMIN
    for(int i = 0; i < dk - 1; i++)
    {
        ll kek = 1;
        mi = d[i];
        ma = d[i] * 2;
  //      cout << gd[ma]  << ' '<< gd[mi] << endl;
        kek *= gd[ma] - gd[mi];
   //     cout << kek << endl;
        kek *= dd[ma] - dd[mi];
   //     cout << kek << endl;

        m = fd[ma] - fd[mi];
        kek *= m * (m - 1) * (m - 2) / 6;
   //     cout << kek << endl;

        ans += kek;
    }
    //FMIN
    for(int i = 0; i < fk - 2; i++)
    {
        ll kek = 1;
        mi = f[i];
        ma = f[i] * 2;

        kek *= gd[ma] - gd[mi];

        m = dd[ma] - dd[mi];
        kek *= m * (m - 1) / 2;

        m = fd[ma] - fd[mi];
        kek *= m * (m - 1) / 2;

        ans += kek;
    }

    cout << ans;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define np(v) next_permutation(v.begin(), v.end())
#define pll pair < long long, long long>
#define all(a) a.begin(), a.end()
#define ull unsigned long long
#define pii pair < int, int >
#define sz(a) (int)a.size()
#define sqr(x) ((x) * (x))
#define y1 stupid_cmath
#define vi vector <int>
#define pb push_back
#define mp make_pair
#define ll long long
#define endl "\n"
#define s second
#define f first
#define tm asdasd

const int inf = (int)1e9 + 9;
const int mod = (int)1e9 + 7;
const int N = 100001;
const double eps = 1e-9;
const double pi = acos(-1.0);

ll g, d, f, ans;
ll x[1111], y[1111], z[1111];
ll pr_g[100100], pr_f[100100], pr_d[100100];

ll calc(ll l, ll r){
    ll cnt_g = pr_g[r] - pr_g[l - 1];
    ll cnt_d = pr_d[r] - pr_d[l - 1];
    ll cnt_f = pr_f[r] - pr_f[l - 1];
    ll a = cnt_g;
    ll b = cnt_d * (cnt_d - 1) / 2;
    ll c = cnt_f * (cnt_f - 1) * (cnt_f - 2) / 6;
    return a * b * c;
}

int main(){
    ios_base::sync_with_stdio(0), cin.tie(0);
    cin >> g >> d >> f;
    for(int i = 1; i <= g; ++i){
        cin >> x[i];
        pr_g[x[i]]++;
    }
    for(int i = 1; i <= d; ++i){
        cin >> y[i];
        pr_d[y[i]]++;
    }
    for(int i = 1; i <= f; ++i){
        cin >> z[i];
        pr_f[z[i]]++;
    }
    for(int i = 1; i <= 100000; ++i){
        pr_g[i] += pr_g[i - 1];
        pr_d[i] += pr_d[i - 1];
        pr_f[i] += pr_f[i - 1];
    }
    for(int i = 1; i <= 50000; ++i){
        if(i == 1){
            ans += calc(i, i + i);
        }else{
            ans += calc(i, i + i) - calc(i, i + i - 2);
        }
    }
    cout << ans << endl;
}


#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

int main()
{
	long long int g, d, f;
	long long int cg = 0, cd = 0, cf = 0;
	long long int ans = 0;
	vector< pair<long long int, long long int> > a;
	cin >> g >> d >> f;

	for(long long int i = 0; i < g; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 1));
	}

	for(long long int i = 0; i < d; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 2));
	}

	for(long long int i = 0; i < f; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 3));
	}

	sort(a.begin(), a.end());

	long long int check = 0;
	cg = 0;
	cd = 0;
	cf = 0;
//	cout << a.size() << endl;
	for(long long int i = 0; i < a.size(); i++)
	{

		if(i > 0)
		{
			if(a[i - 1].S == 1 && cg > 0)
				cg--;
			if(a[i - 1].S == 2 && cd > 0)
				cd--;
			if(a[i - 1].S == 3 && cf > 0)
				cf--;
		}
		for(long long int j = check; j < a.size(); j++)
		{
			if(a[j].F <= 2 * a[i].F)
			{
				check = j + 1;
				if(a[j].S == 1)
					cg++;
				if(a[j].S == 2)
					cd++;
				if(a[j].S == 3)
					cf++;
			}
			else
				break;
		}

		if(cg < 1 || cd < 2 || cf < 3)
				continue;

		//cout << cg * cd * (cd - 1) / 2 * cf * (cf - 1) * (cf - 2) / 6 << ' ' << check << endl;
		ans += cg * cd * (cd - 1) / 2 * cf * (cf - 1) * (cf - 2) / 6;
		if(check >= a.size())
			break;
	}
	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

int bin(int n, int k)
{
    if (k == 0)
        return 1;
    else if (k == 1)
        return n;
    else if (k == 2)
        return (n * (n - 1)) / 2;
    else if (k == 3)
        return (n * (n - 1) * (n - 2)) / 6;
}

int main()
{
	long long int g, d, f;
	vector< pair<long long int, long long int> > a;
	cin >> g >> d >> f;

	for(long long int i = 0; i < g; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 1));
	}

	for(long long int i = 0; i < d; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 2));
	}

	for(long long int i = 0; i < f; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 3));
	}

	sort(a.begin(), a.end());

//	cout << a.size() << endl;
	long long int ans = 0;

	for(long long int i = 0; i < a.size(); i++)
	{
		long long int cg, cd, cf;
		cg = cd = cf = 0;

		for(long long int j = i + 1; j < a.size(); j++)
		{
			if(a[j].F > 2 * a[i].F)
				break;
			if(a[j].S == 1)
				cg++;
			if(a[j].S == 2)
				cd++;
			if(a[j].S == 3)
				cf++;
		}
		int arr[] = {1, 2, 3};
		arr[a[i].S - 1]--;
		long long int x = bin(cg, arr[0]) * bin(cd, arr[1]) * bin(cf, arr[2]);
		ans += x;
	}
	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

int main()
{
	int g, d, f;
	long long int cg = 0, cd = 0, cf = 0;
	long long int ans = 0;
	vector< pair<int, int> > a;
	cin >> g >> d >> f;

	for(int i = 0; i < g; i++)
	{
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 1));
	}

	for(int i = 0; i < d; i++)
	{
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 2));
	}

	for(int i = 0; i < f; i++)
	{
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 3));
	}

	sort(a.begin(), a.end());

	int check = 0;
	cg = 0;
	cd = 0;
	cf = 0;
	for(int i = 0; i < a.size(); i++)
	{
		if(i > 0)
		{
			if(a[i - 1].S == 1)
				cg--;
			if(a[i - 1].S == 2)
				cd--;
			if(a[i - 1].S == 3)
				cf--;
		}
		for(int j = check; j < a.size(); j++)
		{
			if(a[j].F <= 2 * a[i].F)
			{
				check = j + 1;
				if(a[j].S == 1)
					cg++;
				if(a[j].S == 2)
					cd++;
				if(a[j].S == 3)
					cf++;
			}
			else
				break;
		}

		if(cg < 1 || cd < 2 || cf < 3)
				continue;
		ans += cg * cd * (cd - 1) / 2 * cf * (cf - 1) * (cf - 2) / 6;
	}
	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

int bin(int n, int k)
{
    if (k == 0)
        return 1;
    else if (k == 1)
        return n;
    else if (k == 2)
        return (n * (n - 1)) / 2;
    else if (k == 3)
        return (n * (n - 1) * (n - 2)) / 6;
}

int main()
{
	long long int g, d, f;
	long long int ans = 0;
	vector< pair<long long int, long long int> > a;
	cin >> g >> d >> f;

	for(long long int i = 0; i < g; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 1));
	}

	for(long long int i = 0; i < d; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 2));
	}

	for(long long int i = 0; i < f; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 3));
	}

	sort(a.begin(), a.end());

//	cout << a.size() << endl;
	for(long long int i = 0; i < a.size(); i++)
	{
		long long int cg, cd, cf;
		cg = cd = cf = 0;

		for(long long int j = i + 1; j < a.size(); j++)
		{
			if(a[j].F > 2 * a[i].F)
				break;
			if(a[j].S == 1)
				cg++;
			if(a[j].S == 2)
				cd++;
			if(a[j].S == 3)
				cf++;
		}
		int arr[] = {1, 2, 3};
		arr[a[i].S - 1]--;
		ans += bin(cg, arr[0]) * bin(cd, arr[1]) * bin(cf, arr[2]);
	}
	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

long long bin(long long n, long long k)
{
    if (k == 0)
        return 1;
    else if (k == 1)
        return n;
    else if (k == 2)
        return (n * (n - 1)) / 2;
    else if (k == 3)
        return (n * (n - 1) * (n - 2)) / 6;
}

int main()
{
	long long int g, d, f;
	vector< pair<long long int, long long int> > a;
	cin >> g >> d >> f;

	for(long long int i = 0; i < g; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 1));
	}

	for(long long int i = 0; i < d; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 2));
	}

	for(long long int i = 0; i < f; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 3));
	}

	sort(a.begin(), a.end());

//	cout << a.size() << endl;
	long long int ans = 0;

	for(long long int i = 0; i < a.size(); i++)
	{
		long long int cg, cd, cf;
		cg = cd = cf = 0;

		for(long long int j = i + 1; j < a.size(); j++)
		{
			if(a[j].F > 2 * a[i].F)
				break;
			if(a[j].S == 1)
				cg++;
			if(a[j].S == 2)
				cd++;
			if(a[j].S == 3)
				cf++;
		}
		int arr[] = {1, 2, 3};
		arr[a[i].S - 1]--;
		long long int x = bin(cg, arr[0]) * bin(cd, arr[1]) * bin(cf, arr[2]);
		ans += x;
	}
	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

int bin(int n, int k)
{
    if (k == 0)
        return 1;
    else if (k == 1)
        return n;
    else if (k == 2)
        return (n * (n - 1)) / 2;
    else if (k == 3)
        return (n * (n - 1) * (n - 2)) / 6;
}

int main()
{
	long long int g, d, f;
	long long int ans = 0;
	vector< pair<long long int, long long int> > a;
	cin >> g >> d >> f;

	for(long long int i = 0; i < g; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 1));
	}

	for(long long int i = 0; i < d; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 2));
	}

	for(long long int i = 0; i < f; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 3));
	}

	sort(a.begin(), a.end());

//	cout << a.size() << endl;
	for(long long int i = 0; i < a.size(); i++)
	{
		long long int cg, cd, cf;
		cg = cd = cf = 0;

		for(long long int j = i + 1; j < a.size(); j++)
		{
			if(a[j].F <= 2 * a[i].F)
			{
				if(a[j].S == 1)
					cg++;
				if(a[j].S == 2)
					cd++;
				if(a[j].S == 3)
					cf++;
			}
			else
				break;
		}
		int arr[] = {1, 2, 3};
		arr[a[i].S - 1]--;
		ans += bin(cg, arr[0]) * bin(cd, arr[1]) * bin(cf, arr[2]);
	}
	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

int main()
{
	int g, d, f;
	long long int cg = 0, cd = 0, cf = 0;
	long long int ans = 0;
	vector< pair<int, int> > a;
	cin >> g >> d >> f;

	for(int i = 0; i < g; i++)
	{
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 1));
	}

	for(int i = 0; i < d; i++)
	{
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 2));
	}

	for(int i = 0; i < f; i++)
	{
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 3));
	}

	sort(a.begin(), a.end());

	int check = 0;
	for(int i = 0; i < a.size(); i++)
	{
		int cg = 0;
		int cd = 0;
		int cf = 0;

/*		if(i > 0)
		{
			if(a[i - 1].S == 1)
				cg--;
			if(a[i - 1].S == 2)
				cd--;
			if(a[i - 1].S == 3)
				cf--;
		}
*/		for(int j = i; j < a.size(); j++)
		{
			if(a[j].F <= 2 * a[i].F)
			{
				check = j + 1;
				if(a[j].S == 1)
					cg++;
				if(a[j].S == 2)
					cd++;
				if(a[j].S == 3)
					cf++;
			}
			else
				break;
		}

		if(cg < 1 || cd < 2 || cf < 3)
				continue;
		ans += cg * cd * (cd - 1) / 2 * cf * (cf - 1) * (cf - 2) / 6;
	}
	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

int bin(int n, int k)
{
    if (k == 0)
        return 1;
    else if (k == 1)
        return n;
    else if (k == 2)
        return (n * (n - 1)) / 2;
    else if (k == 3)
        return (n * (n - 1) * (n - 2)) / 6;
}

int main()
{
	long long int g, d, f;
	long long int ans = 0;
	vector< pair<long long int, long long int> > a;
	cin >> g >> d >> f;

	for(long long int i = 0; i < g; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 1));
	}

	for(long long int i = 0; i < d; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 2));
	}

	for(long long int i = 0; i < f; i++)
	{
		long long int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 3));
	}

	sort(a.begin(), a.end());

//	cout << a.size() << endl;
	for(long long int i = 0; i < a.size(); i++)
	{
		long long int cg, cd, cf;
		cg = cd = cf = 0;

		for(long long int j = i + 1; j < a.size(); j++)
		{
			if(a[j].F > 2 * a[i].F)
				break;
			if(a[j].S == 1)
				cg++;
			if(a[j].S == 2)
				cd++;
			if(a[j].S == 3)
				cf++;
		}
		int arr[] = {1, 2, 3};
		arr[a[i].S - 1]--;
		int x = bin(cg, arr[0]) * bin(cd, arr[1]) * bin(cf, arr[2]);
		ans += x;
	}
	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

int main()
{
	int g, d, f;
	int cg = 0, cd = 0, cf = 0;
	long long int ans = 0;
	vector< pair<int, int> > a;
	cin >> g >> d >> f;

	for(int i = 0; i < g; i++)
	{
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 1));
	}

	for(int i = 0; i < d; i++)
	{
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 2));
	}

	for(int i = 0; i < f; i++)
	{
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 3));
	}

	sort(a.begin(), a.end());

	int check = 0;
	cg = 0;
	cd = 0;
	cf = 0;
//	cout << a.size() << endl;
	for(int i = 0; i < a.size(); i++)
	{

		if(i > 0)
		{
			if(a[i - 1].S == 1 && cg > 0)
				cg--;
			if(a[i - 1].S == 2 && cd > 0)
				cd--;
			if(a[i - 1].S == 3 && cf > 0)
				cf--;
		}
		for(int j = check; j < a.size(); j++)
		{
			if(a[j].F <= 2 * a[i].F)
			{
				check = j + 1;
				if(a[j].S == 1)
					cg++;
				if(a[j].S == 2)
					cd++;
				if(a[j].S == 3)
					cf++;
			}
			else
				break;
		}

		if(cg < 1 || cd < 2 || cf < 3)
				continue;

		//cout << cg * cd * (cd - 1) / 2 * cf * (cf - 1) * (cf - 2) / 6 << ' ' << check << endl;
		ans += cg * cd * (cd - 1) / 2 * cf * (cf - 1) * (cf - 2) / 6;
		if(check >= a.size())
			break;
	}
	cout << ans << endl;

	return 0;
}


#include <bits/stdc++.h>

#define F first
#define S second

using namespace std;

int main()
{
	int g, d, f;
	int cg = 0, cd = 0, cf = 0;
	long long int ans = 0;
	vector< pair<int, int> > a;
	cin >> g >> d >> f;

	for(int i = 0; i < g; i++)
	{
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 1));
	}

	for(int i = 0; i < d; i++)
	{
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 2));
	}

	for(int i = 0; i < f; i++)
	{
		int temp;
		cin >> temp;
		a.push_back(make_pair(temp, 3));
	}

	sort(a.begin(), a.end());

	int check = 0;
	cg = 0;
	cd = 0;
	cf = 0;
	for(int i = 0; i < a.size(); i++)
	{

		if(check >= a.size())
			break;

		if(i > 0)
		{
			if(a[i - 1].S == 1)
				cg--;
			if(a[i - 1].S == 2)
				cd--;
			if(a[i - 1].S == 3)
				cf--;
		}
		for(int j = check; j < a.size(); j++)
		{
			if(a[j].F <= 2 * a[i].F)
			{
				check = j + 1;
				if(a[j].S == 1)
					cg++;
				if(a[j].S == 2)
					cd++;
				if(a[j].S == 3)
					cf++;
			}
			else
				break;
		}

		if(cg < 1 || cd < 2 || cf < 3)
				continue;

		//cout << cg * cd * (cd - 1) / 2 * cf * (cf - 1) * (cf - 2) / 6 << ' ' << check << endl;
		ans += cg * cd * (cd - 1) / 2 * cf * (cf - 1) * (cf - 2) / 6;
	}
	cout << ans << endl;

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long num_g[1001] = {}; //������ ������� ��������
long long num_d[1001] = {};
long long num_f[1001] = {};
long long c_a_b[4][1001];

vector<pair<long long, char> > all;
int g, d, f;

int wellGAmount(long long a, long long b) {
	int ans = 0;
	for (int i = 0; i < g; ++i) {
		if (num_g[i] > a) {
			if (num_g[i] <= b) {
				++ans;
			}
			else {
				break;
			}
		}
	}
	return ans;
}
int wellDAmount(long long a, long long b) {
	int ans = 0;
	for (int i = 0; i < d; ++i) {
		if (num_d[i] > a) {
			if (num_d[i] <= b) {
				++ans;
			}
			else {
				break;
			}
		}
	}
	return ans;
}
int wellFAmount(long long a, long long b) {
	int ans = 0;
	for (int i = 0; i < f; ++i) {
		if (num_f[i] > a) {
			if (num_f[i] <= b) {
				++ans;
			}
			else {
				break;
			}
		}
	}
	return ans;
}

void calcC() {
	for (int i = 0; i < 1001; ++i)
		c_a_b[0][i] = 1;
	c_a_b[1][1] = c_a_b[2][2] = c_a_b[3][3] = 1;
	for (int i = 1; i < 4; ++i) {
		for (int j = i + 1; j < 1001; ++j) {
			c_a_b[i][j] = c_a_b[i][j - 1] + c_a_b[i - 1][j - 1];
		}
	}
}

int main() {
	cin >> g >> d >> f;

	for (int i = 0; i < g; ++i) {
		cin >> num_g[i];
		all.emplace_back(num_g[i], 'g');
	}
	for (int i = 0; i < d; ++i) {
		cin >> num_d[i];
		all.emplace_back(num_d[i], 'd');
	}
	for (int i = 0; i < f; ++i) {
		cin >> num_f[i];
		all.emplace_back(num_f[i], 'f');
	}
	calcC();
	std::sort(num_g, &num_g[g]);
	std::sort(num_d, &num_d[d]);
	std::sort(num_f, &num_f[f]);
	std::sort(all.begin(), all.end());

	int end;
	int wellg, welld, wellf;
	pair<long long, char> cur_player;
	long long ans = 0;

	int max_num = all.back().first;
	for (int i = 0; i < g + d + f; ++i) {
		cur_player = all[i];
		end = cur_player.first * 2;
		if (end > max_num)
			break;
		int takeg = 1, taked = 2, takef = 3;
		wellg = wellGAmount(cur_player.first, end);
		welld = wellDAmount(cur_player.first, end);
		wellf = wellFAmount(cur_player.first, end);

		if (cur_player.second == 'g')
			takeg = 0;
		if (cur_player.second == 'd')
			taked = 1;
		if (cur_player.second == 'f')
			takef = 2;

		ans += 1LL* c_a_b[takeg][wellg] * c_a_b[taked][welld] * c_a_b[takef][wellf];
	}
	cout << ans;

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long num_g[1001] = {};
long long num_d[1001] = {};
long long num_f[1001] = {};
long long c_a_b[4][1001];

vector<pair<long long, char> > all;
int g, d, f;

int wellGAmount(long long a, long long b) {
	int ans = 0;
	for (int i = 0; i < g; ++i) {
		if (num_g[i] > a) {
			if (num_g[i] <= b) {
				++ans;
			}
			else {
				break;
			}
		}
	}
	return ans;
}
int wellDAmount(long long a, long long b) {
	int ans = 0;
	for (int i = 0; i < d; ++i) {
		if (num_d[i] > a) {
			if (num_d[i] <= b) {
				++ans;
			}
			else {
				break;
			}
		}
	}
	return ans;
}
int wellFAmount(long long a, long long b) {
	int ans = 0;
	for (int i = 0; i < f; ++i) {
		if (num_f[i] > a) {
			if (num_f[i] <= b) {
				++ans;
			}
			else {
				break;
			}
		}
	}
	return ans;
}

void calcC() {
	for (int i = 0; i < 1001; ++i)
		c_a_b[0][i] = 1;
	c_a_b[1][1] = c_a_b[2][2] = c_a_b[3][3] = 1;
	for (int i = 1; i < 4; ++i) {
		for (int j = i + 1; j < 1001; ++j) {
			c_a_b[i][j] = c_a_b[i][j - 1] + c_a_b[i - 1][j - 1];
		}
	}
}

int main() {
	cin >> g >> d >> f;

	for (int i = 0; i < g; ++i) {
		cin >> num_g[i];
		all.emplace_back(num_g[i], 'g');
	}
	for (int i = 0; i < d; ++i) {
		cin >> num_d[i];
		all.emplace_back(num_d[i], 'd');
	}
	for (int i = 0; i < f; ++i) {
		cin >> num_f[i];
		all.emplace_back(num_f[i], 'f');
	}
	calcC();
	std::sort(num_g, &num_g[g]);
	std::sort(num_d, &num_d[d]);
	std::sort(num_f, &num_f[f]);
	std::sort(all.begin(), all.end());

	int end;
	int wellg, welld, wellf;
	pair<long long, char> cur_player;
	long long ans = 0;

	int max_num = all.back().first;
	for (int i = 0; i < g + d + f; ++i) {
		cur_player = all[i];
		end = cur_player.first * 2;
		int takeg = 1, taked = 2, takef = 3;
		wellg = wellGAmount(cur_player.first, end);
		welld = wellDAmount(cur_player.first, end);
		wellf = wellFAmount(cur_player.first, end);

		if (cur_player.second == 'g')
			takeg = 0;
		if (cur_player.second == 'd')
			taked = 1;
		if (cur_player.second == 'f')
			takef = 2;

		ans += 1LL* c_a_b[takeg][wellg] * c_a_b[taked][welld] * c_a_b[takef][wellf];
	}
	cout << ans;

	return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sqr(x) ((x)*(x))
#define forn(i,a,n) for(int i  = a;i<(int)n;i++)
#define dforn(i,a,n) for(int i = n-1;i>=a;i--)

using namespace std;

int main()
{
    #ifdef Home
    	freopen("in.txt","r",stdin);
    	freopen("out.txt","w",stdout);
    #endif
    int g,d,f;
    scanf("%d %d %d", &g, &d, &f);

    long long ans = 0;

 	vector<pair<int, char>>players(g+d+f, make_pair(0,' '));
 	forn(i,0,g){
 		scanf("%d", &players[i].f);
 		players[i].s = 'g';
 	}

 	forn(i,0,d){
 		scanf("%d", &players[g+i].f);
 		players[g+i].s = 'd';
 	}

 	forn(i,0,f){
 		scanf("%d", &players[g+d+i].f);
 		players[g+d+i].s = 'f';
 	}

    sort(players.begin(), players.end());

    int l = 0;
    int r = 0;
    int gs = 0;
    int ds = 0;
    int fs = 0;

    if(players[0].s=='g')
    	gs++;
    else if(players[0].s == 'd')
    	ds++;
    else
    	fs++;

    while(l<=r){
        int prev = r;
        while(r+1<g+d+f&&players[r+1].f<=2*players[l].f){
    		r++;

    		if(players[r].s=='g')
    			gs++;
    		else if(players[r].s == 'd')
    			ds++;
    		else
    			fs++;
    	}

    	if(prev!=r&&gs>0&&ds>1&&fs>2){
    		ans+=1LL*gs*(ds*(ds-1)/2)*(fs*(fs-1)*(fs-2)/6);
    	}

    	if(players[l].s=='g')
    		gs--;
    	else if(players[l].s == 'd')
    		ds--;
    	else
    		fs--;

    	l++;

    	if(l==r&&r!=g+d+f-1){
    		r++;

    		if(players[r].s=='g')
    			gs++;
    		else if(players[r].s == 'd')
    			ds++;
    		else
    			fs++;
    	}

    }

    printf("%I64d", ans);
    return 0;
}


#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <functional>

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sqr(x) ((x)*(x))
#define forn(i,a,n) for(int i  = a;i<(int)n;i++)
#define dforn(i,a,n) for(int i = n-1;i>=a;i--)

using namespace std;

int main()
{
    #ifdef Home
    	freopen("in.txt","r",stdin);
    	freopen("out.txt","w",stdout);
    #endif
    int g,d,fo;
    scanf("%d %d %d", &g, &d, &fo);

    long long ans = 0;

	vector<pair<int, char>>players(g+d+fo, make_pair(0,' '));
	forn(i,0,g){
		scanf("%d", &players[i].f);
		players[i].s = 'g';
 	}

 	forn(i,0,d){
 		scanf("%d", &players[g+i].f);
 		players[g+i].s = 'd';
 	}

 	forn(i,0,fo){
 		scanf("%d", &players[g+d+i].f);
 		players[g+d+i].s = 'f';
 	}

    sort(players.begin(), players.end());

    vector<vector<int>>vec(g+d+fo, vector<int>(3,0));

    if(players[0].s=='g')
    	vec[0][0]++;
    else if(players[0].s == 'd')
    	vec[0][1]++;
    else
    	vec[0][2]++;

  	int l = 0;
  	int r = 1;

  	int lastr = 0;

    while(r<g+d+fo){
    	vec[r] = vec[r-1];
        if(players[r].s=='g')
    		vec[r][0]++;
    	else if(players[r].s == 'd')
    		vec[r][1]++;
    	else
    		vec[r][2]++;

        while(l<r&&(2*players[l].f<players[r].f))
    		l++;

        int gs = vec[r][0]-vec[l][0];
        int ds = vec[r][1]-vec[l][1];
        int fs = vec[r][2]-vec[l][2];
        if(players[l].s == 'g')
        	gs++;
        else if(players[l].s == 'd')
        	ds++;
        else
        	fs++;

        if(gs>0&&ds>1&&fs>2){
        	//ans+=1LL*gs*(ds*(ds-1)/2)*(fs*(fs-1)*(fs-2)/6);

        	ans+=1LL*gs*(ds*(ds-1)/2)*(fs*(fs-1)*(fs-2)/6);

        	lastr = max(lastr, l);
        	gs = vec[lastr][0]-vec[l][0];
        	ds = vec[lastr][1]-vec[l][1];
        	fs = vec[lastr][2]-vec[l][2];

        	if(players[l].s == 'g')
        		gs++;
       		else if(players[l].s == 'd')
        		ds++;
        	else
        		fs++;

        	if(gs>0&&ds>1&&fs>2)
        		ans-=1LL*gs*(ds*(ds-1)/2)*(fs*(fs-1)*(fs-2)/6);

        	lastr = r;
        }

	  	r++;
    }

    printf("%I64d", ans);
    return 0;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

struct player {
    unsigned long long number;
    char role;

    player(unsigned long long number, char role) {
        this->number = number;
        this->role = role;
    }
};

bool operator < (player a, player b) {
    return a.number < b.number;
}

int main() {
    int g, d, f;
    cin >> g >> d >> f;
    vector<player> goalkeepers;
    vector<player> defenders;
    vector<player> fighters;
    vector<player> all;
    for (int i = 0; i < g; ++i) {
        int number;
        cin >> number;
        player cur_player(number, 'g');
        goalkeepers.push_back(cur_player);
        all.push_back(cur_player);
    }
    for (int i = 0; i < d; ++i) {
        int number;
        cin >> number;
        player cur_player(number, 'd');
        defenders.push_back(cur_player);
        all.push_back(cur_player);
    }
    for (int i = 0; i < f; ++i) {
        int number;
        cin >> number;
        player cur_player(number, 'f');
        fighters.push_back(cur_player);
        all.push_back(cur_player);
    }
    sort(goalkeepers.begin(), goalkeepers.end());
    sort(defenders.begin(), defenders.end());
    sort(fighters.begin(), fighters.end());
    sort(all.begin(), all.end());
    int gl = 0;
    int dl = 0;
    int fl = 0;
    int gr = 0;
    int dr = 0;
    int fr = 0;
    int n_total = g + d + f;
    unsigned long long ans = 0;
    for (int pos = 0; pos < n_total; ++pos) {
        unsigned int left_border = all[pos].number;
        unsigned int right_border = left_border << 1;
        while (gl < g && goalkeepers[gl].number <= left_border) {
            ++gl;
        }
        while (dl < d && defenders[dl].number <= left_border) {
            ++dl;
        }
        while (fl < f && fighters[fl].number <= left_border) {
            ++fl;
        }
        while (gr < g && goalkeepers[gr].number <= right_border) {
            ++gr;
        }
        while (dr < d && defenders[dr].number <= right_border) {
            ++dr;
        }
        while (fr < f && fighters[fr].number <= right_border) {
            ++fr;
        }
        unsigned long long gn = gr - gl;
        unsigned long long dn = dr - dl;
        unsigned long long fn = fr - fl;
        switch (all[pos].role) {
            case 'g': {
                ans += dn * (dn - 1) * fn * (fn - 1) * (fn - 2) / 12;
                break;
            }
            case 'd': {
                ans += gn * dn * fn * (fn - 1) * (fn - 2) / 6;
                break;
            }
            case 'f': {
                ans += gn * dn * (dn - 1) * fn * (fn - 1) / 4;
                break;
            }
        }
    }
    cout << ans;

    return 0;
}


#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

struct player {
    unsigned int number;
    char role;

    player(unsigned int number, char role) {
        this->number = number;
        this->role = role;
    }
};

bool operator < (player a, player b) {
    return a.number < b.number;
}

int main() {
    int g, d, f;
    cin >> g >> d >> f;
    vector<player> goalkeepers;
    vector<player> defenders;
    vector<player> fighters;
    for (int i = 0; i < g; ++i) {
        int number;
        cin >> number;
        player cur_player(number, 'g');
        goalkeepers.push_back(cur_player);
    }
    for (int i = 0; i < d; ++i) {
        int number;
        cin >> number;
        player cur_player(number, 'd');
        defenders.push_back(cur_player);
    }
    for (int i = 0; i < f; ++i) {
        int number;
        cin >> number;
        player cur_player(number, 'f');
        fighters.push_back(cur_player);
    }
    vector<player> all;
    for (player p: goalkeepers) {
        all.push_back(p);
    }
    for (player p: defenders) {
        all.push_back(p);
    }
    for (player p: fighters) {
        all.push_back(p);
    }
    sort(goalkeepers.begin(), goalkeepers.end());
    sort(defenders.begin(), defenders.end());
    sort(fighters.begin(), fighters.end());
    sort(all.begin(), all.end());
    int pos = 0;
    int gl = 0;
    int dl = 0;
    int fl = 0;
    int gr = 0;
    int dr = 0;
    int fr = 0;
    int n_total = g + d + f;
    unsigned long long ans = 0;
    while (pos < n_total) {
        unsigned int left_border = all[pos].number;
        unsigned int right_border = left_border << 1;
        while (gl < g && goalkeepers[gl].number <= left_border) {
            ++gl;
        }
        while (dl < d && defenders[dl].number <= left_border) {
            ++dl;
        }
        while (fl < f && fighters[fl].number <= left_border) {
            ++fl;
        }
        while (gr < g && goalkeepers[gr].number <= right_border) {
            ++gr;
        }
        while (dr < d && defenders[dr].number <= right_border) {
            ++dr;
        }
        while (fr < f && fighters[fr].number <= right_border) {
            ++fr;
        }
        int gn = gr - gl;
        int dn = dr - dl;
        int fn = fr - fl;
        switch (all[pos].role) {
            case 'g': {
                ans += dn * (dn - 1) * fn * (fn - 1) * (fn - 2) / 12;
                break;
            }
            case 'd': {
                ans += gn * dn * fn * (fn - 1) * (fn - 2) / 6;
                break;
            }
            case 'f': {
                ans += gn * dn * (dn - 1) * fn * (fn - 1) / 4;
                break;
            }
        }
        ++pos;
    }
    cout << ans;

    return 0;
}


#define TASKNAME "text"

#include <bits/stdc++.h>

#define sz(a) (int)a.size()
#define all(a) (a).begin(), (a).end()
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const double EPS = 1e-9;
const int maxn = 1e5;

long long cnt(const vector<int> &a, int c, int ln, int rn) {
    int l = lower_bound(a.begin(), a.end(), ln) - a.begin();
    int r = upper_bound(a.begin(), a.end(), rn) - a.begin() - 1;
    long long s = max(0, r - l + 1);
    long long answer = 1;
    for (int i = 0; i < c; i++) {
        answer *= s;
        s--;
    }
    for (int i = 0; i < c; i++) {
        answer /= i + 1;
    }
    return answer;
}

int main() {
    #ifdef LocalHost
    freopen(TASKNAME".in", "r", stdin);
    freopen(TASKNAME".out", "w", stdout);
    #endif
    int g, d, f;
    scanf("%d%d%d", &g, &d, &f);
    vector<int> a(g), b(d), c(f);
    for (int i = 0; i < g; i++) scanf("%d", &a[i]);
    for (int i = 0; i < d; i++) scanf("%d", &b[i]);
    for (int i = 0; i < f; i++) scanf("%d", &c[i]);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    vector<pair<int, int>> all;
    for (int i = 0; i < g; i++) all.push_back({a[i], 1});
    for (int i = 0; i < d; i++) all.push_back({b[i], 2});
    for (int i = 0; i < f; i++) all.push_back({c[i], 3});
    long long answer = 0;
    for (int i = 0; i < (int)all.size(); i++) {
        for (int j = i + 1; j < (int)all.size(); j++) {
            if (all[i].second == 1 && all[j].second == 1) continue;
            int mn = min(all[i].first, all[j].first);
            int mx = max(all[i].first, all[j].first);
            if (mn * 2 < mx) continue;
            vector<int> cc = {1, 2, 3};
            cc[all[i].second - 1]--;
            cc[all[j].second - 1]--;
            long long add = cnt(a, cc[0], mn + 1, mx - 1) * cnt(b, cc[1], mn + 1, mx - 1) * cnt(c, cc[2], mn + 1, mx - 1);
            //cerr << all[i].first << ' ' << all[i].second << ' ' << all[j].first << ' ' << all[j].second << ' ' << add << '\n';
            answer += add;
        }
    }
    printf("%lld\n", answer);
    return 0;
}


#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
long long soc(int n, int k){
  if (k==3){
    return n*(n-1)*(n-2)/6;
  }
  else
    return n*(n-1)/2;
}

bool comp (pair <int, int> a, pair <int, int> b){
  return a.first<b.first;
}

int main() {
  int g, d, f;
  cin >>g>>d>>f;
  vector <pair<int, int> > a(g+d+f);
  int check[3]={0, 0, 0};
  int x;
  for (int i=0;i<g;i++){
    cin >>x;
    a[i]=pair<int, int> (x, 1);
  }
  for (int i=0;i<d;i++){
    cin >>x;
    a[i+g]=pair<int, int> (x, 2);
  }
  for (int i=0;i<f;i++){
    cin >>x;
    a[i+g+d]=pair<int, int> (x, 3);
  }
  sort(a.begin(), a.end(), comp);
  // for (int i=0;i<g+d+f;i++)
  //   cout <<a[i].first<<" "<<a[i].second<<endl;
    if (g+d+f < 6){
    cout <<0;
    return 0;
  }
  for (int i=0;i<6;i++){
    check[a[i].second-1]++;
  }
  int i=0, j=6;
  unsigned long long res=0;
  if (a[0].first*2>=a[5].first)
    res=check[0]*soc(check[1], 2)*soc(check[2], 3);
  else
    res=0;
  // cout <<res<<"!"<<endl;
  for (;i<g+d+f;i++){
    for (;j<g+f+d && a[i].first*2>=a[j].first;j++){
      if (res==0){
        check[a[j].second-1]++;
        if (check[0]>=1 && check[2]>=2 && check[3]>=3)
          res=check[0]*soc(check[1], 2)*soc(check[2], 3);
        continue;
      }
      if (a[j].second==1){
        res+=soc(check[1], 2)*soc(check[2], 3);
      }
      if (a[j].second==2){
        res+=check[0]*check[1]*soc(check[2], 3);
      }
      if (a[j].second==3){
        res+=check[0]*soc(check[1], 2)*soc(check[2], 2);
        // cout <<j<<" "<<check[0]<<" "<<check[1]<<" "<<check[2]<<" "<< check[0]*soc(check[1], 2)*soc(check[2], 2)<<endl;
      }
      check[a[j].second-1]++;
    }
    check[a[i].second-1]--;
  }
  cout <<res;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define fr(i,n)    for(int i=0;i<n;i++)
#define fru(i,a,b) for(int i=a;i<=b;i++)
#define frd(i,a,b) for(int i=a;i>=b;i--)

typedef long long   ll;
typedef long double ld;

const int INF = 2e9 + 10;
const int MOD = 1e9 + 7;
const int N   = 1e3 + 10;

int g, d, f, v;
vector<int> arrg, arrd, arrf;

int searchL(int v, vector<int> &vec) {

   int l = 0;
   int r = vec.size() - 1;

   while(r - l > 1) {
      int mid = (l + r) / 2;

      if(vec[mid] > v) {
         r = mid;
      } else {
         l = mid;
      }
   }

   return (vec[l] >= v ? l : r);
}

int searchR(int v, vector<int> &vec) {

   int l = 0;
   int r = vec.size() - 1;

   while(r - l > 1) {
      int mid = (l + r) / 2;

      if(vec[mid] < v) {
         l = mid;
      } else {
         r = mid;
      }
   }

   return (vec[r] <= v ? r : l);
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.tie(0); cin.tie(0);

   cin >> g >> d >> f;

   fru(i, 1, g) {
      cin >> v;
      arrg.push_back(v);
   }

   fru(i, 1, d) {
      cin >> v;
      arrd.push_back(v);
   }

   fru(i, 1, f) {
      cin >> v;
      arrf.push_back(v);
   }

   sort(arrg.begin(), arrg.end());
   sort(arrd.begin(), arrd.end());
   sort(arrf.begin(), arrf.end());

   int ans = 0;
   fr(i, g) {

      int j_le = searchL((int)ceil(1.0 * arrg[i] / 2), arrd);
      int j_ri = searchR(2 * arrg[i], arrd);

      fru(j, j_le, j_ri) {

         int k_le = searchL((int)ceil(1.0 * max(arrg[i], arrd[j]) / 2), arrf);
         int k_ri = searchR(2 * min(arrg[i], arrd[j]), arrf);

         fru(k, k_le, k_ri) {

            if((int)ceil(1.0 * max(arrg[i], arrd[j]) / 2) > arrf[k]) {
               continue;
            }

            int _ri = 2 * min(min(arrg[i], arrd[j]), arrf[k]);

            int ind_d = searchR(_ri, arrd);
            int ind_f = searchR(_ri, arrf);

            ans += (ind_d - j) * (ind_f - k) * (ind_f - k - 1) / 2;
         }
      }
   }

   cout << ans;

   return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define fr(i,n)    for(int i=0;i<n;i++)
#define fru(i,a,b) for(int i=a;i<=b;i++)
#define frd(i,a,b) for(int i=a;i>=b;i--)

typedef long long   ll;
typedef long double ld;

const int INF = 2e9 + 10;
const int MOD = 1e9 + 7;
const int N   = 3e3 + 10;

int g, d, f, v, n;
struct POINT {
   int v;
   int t;
   bool operator < (const POINT &e) const { return v < e.v; }
} a[N];

int cnt[10];

int searchR(int v) {

   int l = 1;
   int r = n;

   while(r - l > 1) {
      int mid = (l + r) / 2;

      if(a[mid].v < v) {
         l = mid;
      } else {
         r = mid;
      }
   }

   return (a[r].v <= v ? r : l);
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.tie(0); cin.tie(0);

   cin >> g >> d >> f;

   n = g + d + f;

   fru(i, 1, g) {
      cin >> v;
      a[i].v = v;
      a[i].t = 1;
   }

   fru(i, g + 1, g + d) {
      cin >> v;
      a[i].v = v;
      a[i].t = 2;
   }

   fru(i, g + d + 1, g + d + f) {
      cin >> v;
      a[i].v = v;
      a[i].t = 3;
   }

   sort(a + 1, a + 1 + n);

   ll ans  = 0;
   int pos = 1;

   fru(i, 1, n) {

      if(i > 1) {
         cnt[a[i - 1].t]--;
      }

      int ri = searchR(2 * a[i].v);

      fru(j, pos, ri) {
         cnt[a[j].t]++;
      }
      pos = ri + 1;

      ll v1 = cnt[1];
      ll v2 = (1LL * cnt[2] * (cnt[2] - 1) / 2);
      ll v3 = (1LL * cnt[3] * (cnt[3] - 1) * (cnt[3] - 2) / 6);

      if(a[i].t == 1) {
         v1 = 1;
      } else if(a[i].t == 2) {
         v2 = cnt[2] - 1;
      } else {
         v3 = (1LL * (cnt[3] - 1) * (cnt[3] - 2) / 2);
      }

      ans += v1 * v2 * v3;
   }

   cout << ans;

   return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define fr(i,n)    for(int i=0;i<n;i++)
#define fru(i,a,b) for(int i=a;i<=b;i++)
#define frd(i,a,b) for(int i=a;i>=b;i--)

typedef long long   ll;
typedef long double ld;

const int INF = 2e9 + 10;
const int MOD = 1e9 + 7;
const int N   = 1e3 + 10;

int g, d, f, v;
vector<int> arrg, arrd, arrf;

int searchL(int v, vector<int> &vec) {

   int l = 0;
   int r = vec.size() - 1;

   while(r - l > 1) {
      int mid = (l + r) / 2;

      if(vec[mid] > v) {
         r = mid;
      } else {
         l = mid;
      }
   }

   return (vec[l] >= v ? l : r);
}

int searchR(int v, vector<int> &vec) {

   int l = 0;
   int r = vec.size() - 1;

   while(r - l > 1) {
      int mid = (l + r) / 2;

      if(vec[mid] < v) {
         l = mid;
      } else {
         r = mid;
      }
   }

   return (vec[r] <= v ? r : l);
}

int main() {
   ios_base::sync_with_stdio(0);
   cout.tie(0); cin.tie(0);

   cin >> g >> d >> f;

   fru(i, 1, g) {
      cin >> v;
      arrg.push_back(v);
   }

   fru(i, 1, d) {
      cin >> v;
      arrd.push_back(v);
   }

   fru(i, 1, f) {
      cin >> v;
      arrf.push_back(v);
   }

   sort(arrg.begin(), arrg.end());
   sort(arrd.begin(), arrd.end());
   sort(arrf.begin(), arrf.end());

   ll ans = 0;
   fr(i, g) {

      int j_le = searchL((int)ceil(1.0 * arrg[i] / 2), arrd);
      int j_ri = searchR(2 * arrg[i], arrd);

      fru(j, j_le, j_ri) {

         int k_le = searchL((int)ceil(1.0 * max(arrg[i], arrd[j]) / 2), arrf);
         int k_ri = searchR(2 * min(arrg[i], arrd[j]), arrf);

         fru(k, k_le, k_ri) {

            if((int)ceil(1.0 * max(arrg[i], arrd[j]) / 2) > arrf[k]) {
               continue;
            }

            int _ri = 2 * min(min(arrg[i], arrd[j]), arrf[k]);

            int ind_d = searchR(_ri, arrd);
            int ind_f = searchR(_ri, arrf);

            ans += 1LL * (ind_d - j) * (ind_f - k) * (ind_f - k - 1) / 2;
         }
      }
   }

   cout << ans;

   return 0;
}


#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;

struct TeamMember
{
	unsigned char type;
	int number; // от 1 до 100000
};

struct sort_fn
{
	inline bool operator() (const TeamMember& struct1, const TeamMember& struct2)
	{
		return (struct1.number > struct2.number);
	}
};

unsigned long get_variants(int n, int k) {
	if (k > n) return 0;
	if (k * 2 > n) k = n - k;
	if (k == 0) return 1;

	unsigned long result = n;
	for (int i = 2; i <= k; ++i) {
		result *= (n - i + 1);
		result /= i;
	}
	return result;
}

int main()
{
	unsigned short g, d, f; // 1 <= x <= 1000

	cin >> g; cin >> d; cin >> f;

	vector<TeamMember> members(g + d + f); // x <= 1000

	vector<TeamMember> team;

	unsigned long variants = 0;

	for (unsigned short i = 0; i < g; i++) {
		cin >> members[i].number;
		members[i].type = 1; // g
	}

	for (unsigned short i = g; i < g + d; i++) {
		cin >> members[i].number;
		members[i].type = 2; // d
	}

	for (unsigned short i = g + d; i < g + d + f; i++) {
		cin >> members[i].number;
		members[i].type = 3; // f
	}

	sort(members.begin(), members.end(), sort_fn());

	for (int i = 0; i < g + d + f; i++) {
		team.push_back(members[i]);

		int size = team.size();

		while ((double)team[0].number / 2 > team[size - 1].number) {
			team.erase(team.begin());
			size--;
			if (size == 0) break;
		}

		if (size < 6) continue;

		int g_members = 0;
		int d_members = 0;
		int f_members = 0;

		for (int j = 0; j < size; j++) {
			switch (team[j].type) {
			case 1:
				g_members++;
				break;
			case 2:
				d_members++;
				break;
			case 3:
				f_members++;
				break;
			}
		}

		if (g_members > 0 && d_members > 1 && f_members > 2) {

			unsigned long g_variants = get_variants(g_members, 1);
			unsigned long d_variants = get_variants(d_members, 2);
			unsigned long f_variants = get_variants(f_members, 3);

			if (members[i].type == 1 && g_members > 1) {
				g_variants -= get_variants(g_members - 1, 1);
			}
			if (members[i].type == 2 && d_members > 2) {
				d_variants -= get_variants(d_members - 1, 2);
			}
			if (members[i].type == 3 && f_members > 3) {
				f_variants -= get_variants(f_members - 1, 3);
			}

			variants += g_variants * d_variants * f_variants;
		}
	}

	cout << variants;

	return 0;
}


#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;

struct TeamMember
{
	unsigned char type;
	int number; // от 1 до 100000
};

struct sort_fn
{
	inline bool operator() (const TeamMember& struct1, const TeamMember& struct2)
	{
		return (struct1.number > struct2.number);
	}
};

unsigned int fact(int x, int from = 1) {
	unsigned int p = 1;
	for (int i = from; i <= x; i++) {
		p *= i;
	}
	return p;
}

int get_variants(int n, int m, bool from) {
	if (from) {
		return fact(n, n - 1) / (fact(m) * fact(n - m, n - 1 - m));
	}
	else {
		return fact(n) / (fact(m) * fact(n - m));
	}

}

int main()
{
	unsigned short g, d, f; // 1 <= x <= 1000

	cin >> g; cin >> d; cin >> f;

	vector<TeamMember> members(g + d + f); // x <= 1000

	vector<TeamMember> team;

	unsigned int variants = 0;

	for (unsigned short i = 0; i < g; i++) {
		cin >> members[i].number;
		members[i].type = 1; // g
	}

	for (unsigned short i = g; i < g + d; i++) {
		cin >> members[i].number;
		members[i].type = 2; // d
	}

	for (unsigned short i = g + d; i < g + d + f; i++) {
		cin >> members[i].number;
		members[i].type = 3; // f
	}

	sort(members.begin(), members.end(), sort_fn());

	for (int i = 0; i < g + d + f; i++) {
		team.push_back(members[i]);

		int size = team.size();

		while ((double)team[0].number / 2 > team[size - 1].number) {
			team.erase(team.begin());
			size--;
			if (size == 0) break;
		}

		if (size < 6) continue;

		int g_members = 0;
		int d_members = 0;
		int f_members = 0;

		for (int j = 0; j < size; j++) {
			switch (team[j].type) {
			case 1:
				g_members++;
				break;
			case 2:
				d_members++;
				break;
			case 3:
				f_members++;
				break;
			}
		}

		if (g_members > 0 && d_members > 1 && f_members > 2) {

			int g_variants = get_variants(g_members, 1, members[i].type == 1 && g_members > 1);
			int d_variants = get_variants(d_members, 2, members[i].type == 2 && d_members > 2);
			int f_variants = get_variants(f_members, 3, members[i].type == 3 && f_members > 3);

			variants += g_variants * d_variants * f_variants;
		}
	}

	cout << variants;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;

struct TeamMember
{
	unsigned char type;
	int number; // от 1 до 100000
};

struct sort_fn
{
	inline bool operator() (const TeamMember& struct1, const TeamMember& struct2)
	{
		return (struct1.number > struct2.number);
	}
};

int get_variants(int n, int k) {
	if (k > n) return 0;
	if (k * 2 > n) k = n - k;
	if (k == 0) return 1;

	int result = n;
	for (int i = 2; i <= k; ++i) {
		result *= (n - i + 1);
		result /= i;
	}
	return result;
}

int main()
{
	unsigned short g, d, f; // 1 <= x <= 1000

	cin >> g; cin >> d; cin >> f;

	vector<TeamMember> members(g + d + f); // x <= 1000

	vector<TeamMember> team;

	unsigned int variants = 0;

	for (unsigned short i = 0; i < g; i++) {
		cin >> members[i].number;
		members[i].type = 1; // g
	}

	for (unsigned short i = g; i < g + d; i++) {
		cin >> members[i].number;
		members[i].type = 2; // d
	}

	for (unsigned short i = g + d; i < g + d + f; i++) {
		cin >> members[i].number;
		members[i].type = 3; // f
	}

	sort(members.begin(), members.end(), sort_fn());

	for (int i = 0; i < g + d + f; i++) {
		team.push_back(members[i]);

		int size = team.size();

		while ((double)team[0].number / 2 > team[size - 1].number) {
			team.erase(team.begin());
			size--;
			if (size == 0) break;
		}

		if (size < 6) continue;

		int g_members = 0;
		int d_members = 0;
		int f_members = 0;

		for (int j = 0; j < size; j++) {
			switch (team[j].type) {
			case 1:
				g_members++;
				break;
			case 2:
				d_members++;
				break;
			case 3:
				f_members++;
				break;
			}
		}

		if (g_members > 0 && d_members > 1 && f_members > 2) {

			int g_variants = get_variants(g_members, 1);
			int d_variants = get_variants(d_members, 2);
			int f_variants = get_variants(f_members, 3);

			if (members[i].type == 1 && g_members > 1) {
				g_variants -= get_variants(g_members - 1, 1);
			}
			if (members[i].type == 2 && d_members > 2) {
				d_variants -= get_variants(d_members - 1, 2);
			}
			if (members[i].type == 3 && f_members > 3) {
				f_variants -= get_variants(f_members - 1, 3);
			}

			variants += g_variants * d_variants * f_variants;
		}
	}

	cout << variants;

	return 0;
}


#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;

struct TeamMember
{
	unsigned char type;
	unsigned short number;
};

struct sort_fn
{
	inline bool operator() (const TeamMember& struct1, const TeamMember& struct2)
	{
		return (struct1.number > struct2.number);
	}
};

unsigned int fact(int x) {
	unsigned int p = 1;
	for (int i = 1; i <= x; i++) {
		p *= i;
	}
	return p;
}

int get_variants(int n, int m) {
	return fact(n) / (fact(m) * fact(n - m));
}

int main()
{
	unsigned short g, d, f; // 1 <= x <= 1000

	cin >> g; cin >> d; cin >> f;

	unsigned short g_members = 0, d_members = 0, f_members = 0; // 1, 2, 3

	vector<TeamMember> members(g + d + f); // x <= 1000

	unsigned int variants = 0;

	for (unsigned short i = 0; i < g; i++) {
		cin >> members[i].number;
		members[i].type = 1; // g
	}

	for (unsigned short i = g; i < g + d; i++) {
		cin >> members[i].number;
		members[i].type = 2; // d
	}

	for (unsigned short i = g + d; i < g + d + f; i++) {
		cin >> members[i].number;
		members[i].type = 3; // f
	}

	sort(members.begin(), members.end(), sort_fn());

	for (int i = 0; i < g + d + f; i++) {
		int prev_j = 0;
		for (int j = i; j <= g + d + f; j++) {
			if (j == g + d + f || members[j].number < (float)members[i].number / 2) {
				if (j != prev_j) {
					variants += get_variants(g_members, 1) * get_variants(d_members, 2) * get_variants(f_members, 3);
					if (j == g + d + f) {
						cout << variants;
						return 0;
					}
					prev_j = j;
				}

				g_members = 0;
				d_members = 0;
				f_members = 0;
				break;
			}
			else {
				switch (members[j].type) {
				case 1:
					g_members++;
					break;
				case 2:
					d_members++;
					break;
				case 3:
					f_members++;
					break;
				}
			}
		}
	}

    return 0;
}


#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;

struct TeamMember
{
	unsigned char type;
	unsigned short number;
};

struct sort_fn
{
	inline bool operator() (const TeamMember& struct1, const TeamMember& struct2)
	{
		return (struct1.number > struct2.number);
	}
};

unsigned int fact(int x) {
	unsigned int p = 1;
	for (int i = 1; i <= x; i++) {
		p *= i;
	}
	return p;
}

int get_variants(int n, int m) {
	return fact(n) / (fact(m) * fact(n - m));
}

int main()
{
	unsigned short g, d, f; // 1 <= x <= 1000

	cin >> g; cin >> d; cin >> f;

	unsigned short g_members = 0, d_members = 0, f_members = 0; // 1, 2, 3

	vector<TeamMember> members(g + d + f); // x <= 1000

	unsigned int variants = 0;

	for (unsigned short i = 0; i < g; i++) {
		cin >> members[i].number;
		members[i].type = 1; // g
	}

	for (unsigned short i = g; i < g + d; i++) {
		cin >> members[i].number;
		members[i].type = 2; // d
	}

	for (unsigned short i = g + d; i < g + d + f; i++) {
		cin >> members[i].number;
		members[i].type = 3; // f
	}

	sort(members.begin(), members.end(), sort_fn());

	for (int i = 0; i < g + d + f; i++) {
		for (int j = i; j <= g + d + f; j++) {
			if (j == g + d + f || members[j].number < (float)members[i].number / 2) {
				variants += get_variants(g_members, 1) * get_variants(d_members, 2) * get_variants(f_members, 3);
				if (j == g + d + f) {
					cout << variants;
					return 0;
				}

				g_members = 0;
				d_members = 0;
				f_members = 0;
				break;
			}
			else {
				switch (members[j].type) {
				case 1:
					g_members++;
					break;
				case 2:
					d_members++;
					break;
				case 3:
					f_members++;
					break;
				}
			}
		}
	}

    return 0;
}


#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;

struct TeamMember
{
	unsigned char type;
	int number; // от 1 до 100000
};

struct sort_fn
{
	inline bool operator() (const TeamMember& struct1, const TeamMember& struct2)
	{
		return (struct1.number > struct2.number);
	}
};

unsigned int fact(int x) {
	unsigned int p = 1;
	for (int i = 1; i <= x; i++) {
		p *= i;
	}
	return p;
}

int get_variants(int n, int m) {
	return fact(n) / (fact(m) * fact(n - m));
}

int main()
{
	unsigned short g, d, f; // 1 <= x <= 1000

	cin >> g; cin >> d; cin >> f;

	vector<TeamMember> members(g + d + f); // x <= 1000

	vector<TeamMember> team;

	unsigned int variants = 0;

	for (unsigned short i = 0; i < g; i++) {
		cin >> members[i].number;
		members[i].type = 1; // g
	}

	for (unsigned short i = g; i < g + d; i++) {
		cin >> members[i].number;
		members[i].type = 2; // d
	}

	for (unsigned short i = g + d; i < g + d + f; i++) {
		cin >> members[i].number;
		members[i].type = 3; // f
	}

	sort(members.begin(), members.end(), sort_fn());

	for (int i = 0; i < g + d + f; i++) {
		team.push_back(members[i]);

		int size = team.size();

		while ((double)team[0].number / 2 > team[size - 1].number) {
			team.erase(team.begin());
			size--;
			if (size == 0) break;
		}

		if (size < 6) continue;

		int g_members = 0;
		int d_members = 0;
		int f_members = 0;

		for (int j = 0; j < size; j++) {
			switch (team[j].type) {
			case 1:
				g_members++;
				break;
			case 2:
				d_members++;
				break;
			case 3:
				f_members++;
				break;
			}
		}

		if (g_members > 0 && d_members > 1 && f_members > 2) {
			if (members[i].type == 1 && g_members > 1 ||
				members[i].type == 2 && d_members > 2 ||
				members[i].type == 3 && f_members > 3
				) {
				for (int j = 0; j < size; j++) {
					if (team[j].type == members[i].type) {
						team.erase(team.begin() + j);
						switch (members[i].type) {
						case 1:
							g_members--;
							break;
						case 2:
							d_members--;
							break;
						case 3:
							f_members--;
							break;
						}
						break;
					}
				}
			}

			variants += get_variants(g_members, 1) * get_variants(d_members, 2) * get_variants(f_members, 3);
		}
	}

	cout << variants;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;

struct TeamMember
{
	unsigned char type;
	int number; // от 1 до 100000
};

struct sort_fn
{
	inline bool operator() (const TeamMember& struct1, const TeamMember& struct2)
	{
		return (struct1.number > struct2.number);
	}
};

unsigned int fact(int x) {
	unsigned int p = 1;
	for (int i = 1; i <= x; i++) {
		p *= i;
	}
	return p;
}

int get_variants(int n, int m) {
	return fact(n) / (fact(m) * fact(n - m));
}

int main()
{
	unsigned short g, d, f; // 1 <= x <= 1000

	cin >> g; cin >> d; cin >> f;

	unsigned short g_members = 0, d_members = 0, f_members = 0; // -> 1, 2, 3

	vector<TeamMember> members(g + d + f); // x <= 1000

	unsigned int variants = 0;

	for (unsigned short i = 0; i < g; i++) {
		cin >> members[i].number;
		members[i].type = 1; // g
	}

	for (unsigned short i = g; i < g + d; i++) {
		cin >> members[i].number;
		members[i].type = 2; // d
	}

	for (unsigned short i = g + d; i < g + d + f; i++) {
		cin >> members[i].number;
		members[i].type = 3; // f
	}

	sort(members.begin(), members.end(), sort_fn());

	for (int i = 0; i < g + d + f; i++) {
		int prev_j = 0;
		for (int j = i; j <= g + d + f; j++) {
			if (j == g + d + f || members[j].number < (double)members[i].number / 2) {
				if (j != prev_j) {
					variants += get_variants(g_members, 1) * get_variants(d_members, 2) * get_variants(f_members, 3);
					if (j == g + d + f) {
						cout << variants;
						return 0;
					}
					prev_j = j;
				}

				g_members = 0;
				d_members = 0;
				f_members = 0;
				break;
			}
			else {
				switch (members[j].type) {
				case 1:
					g_members++;
					break;
				case 2:
					d_members++;
					break;
				case 3:
					f_members++;
					break;
				}
			}
		}
	}

    return 0;
}


#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;

struct TeamMember
{
	unsigned char type;
	int number; // от 1 до 100000
};

struct sort_fn
{
	inline bool operator() (const TeamMember& struct1, const TeamMember& struct2)
	{
		return (struct1.number > struct2.number);
	}
};

unsigned int fact(int x) {
	unsigned int p = 1;
	for (int i = 1; i <= x; i++) {
		p *= i;
	}
	return p;
}

int get_variants(int n, int m) {
	return fact(n) / (fact(m) * fact(n - m));
}

int main()
{
	unsigned short g, d, f; // 1 <= x <= 1000

	cin >> g; cin >> d; cin >> f;

	vector<TeamMember> members(g + d + f); // x <= 1000

	vector<TeamMember> team;

	unsigned int variants = 0;

	for (unsigned short i = 0; i < g; i++) {
		cin >> members[i].number;
		members[i].type = 1; // g
	}

	for (unsigned short i = g; i < g + d; i++) {
		cin >> members[i].number;
		members[i].type = 2; // d
	}

	for (unsigned short i = g + d; i < g + d + f; i++) {
		cin >> members[i].number;
		members[i].type = 3; // f
	}

	sort(members.begin(), members.end(), sort_fn());

	for (int i = 0; i < g + d + f; i++) {
		team.push_back(members[i]);

		int size = team.size();

		while ((double)team[0].number / 2 > team[size - 1].number) {
			team.erase(team.begin());
			size--;
			if (size == 0) break;
		}

		if (size < 6) continue;

		int g_members = 0;
		int d_members = 0;
		int f_members = 0;

		for (int j = 0; j < size; j++) {
			switch (team[j].type) {
			case 1:
				g_members++;
				break;
			case 2:
				d_members++;
				break;
			case 3:
				f_members++;
				break;
			}
		}

		if (g_members > 0 && d_members > 1 && f_members > 2) {

			int g_variants = get_variants(g_members, 1);
			int d_variants = get_variants(d_members, 2);
			int f_variants = get_variants(f_members, 3);

			if (members[i].type == 1 && g_members > 1) {
				g_variants -= get_variants(g_members - 1, 1);
			}
			if (members[i].type == 2 && d_members > 2) {
				d_variants -= get_variants(d_members - 1, 2);
			}
			if (members[i].type == 3 && f_members > 3) {
				f_variants -= get_variants(f_members - 1, 3);
			}

			variants += g_variants * d_variants * f_variants;
		}
	}

	cout << variants;

    return 0;
}


#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>

using namespace std;

struct TeamMember
{
	unsigned char type;
	int number; // от 1 до 100000
};

struct sort_fn
{
	inline bool operator() (const TeamMember& struct1, const TeamMember& struct2)
	{
		return (struct1.number > struct2.number);
	}
};

unsigned long long get_variants(int n, int k) {
	if (k > n) return 0;
	if (k * 2 > n) k = n - k;
	if (k == 0) return 1;

	unsigned long long result = n;
	for (int i = 2; i <= k; ++i) {
		result *= (n - i + 1);
		result /= i;
	}
	return result;
}

int main()
{
	unsigned short g, d, f; // 1 <= x <= 1000

	cin >> g; cin >> d; cin >> f;

	vector<TeamMember> members(g + d + f); // x <= 1000

	vector<TeamMember> team;

	unsigned long long variants = 0;

	for (unsigned short i = 0; i < g; i++) {
		cin >> members[i].number;
		members[i].type = 1; // g
	}

	for (unsigned short i = g; i < g + d; i++) {
		cin >> members[i].number;
		members[i].type = 2; // d
	}

	for (unsigned short i = g + d; i < g + d + f; i++) {
		cin >> members[i].number;
		members[i].type = 3; // f
	}

	sort(members.begin(), members.end(), sort_fn());

	for (int i = 0; i < g + d + f; i++) {
		team.push_back(members[i]);

		int size = team.size();

		while ((double)team[0].number / 2 > team[size - 1].number) {
			team.erase(team.begin());
			size--;
			if (size == 0) break;
		}

		if (size < 6) continue;

		int g_members = 0;
		int d_members = 0;
		int f_members = 0;

		for (int j = 0; j < size; j++) {
			switch (team[j].type) {
			case 1:
				g_members++;
				break;
			case 2:
				d_members++;
				break;
			case 3:
				f_members++;
				break;
			}
		}

		if (g_members > 0 && d_members > 1 && f_members > 2) {

			unsigned long long g_variants = get_variants(g_members, 1);
			unsigned long long d_variants = get_variants(d_members, 2);
			unsigned long long f_variants = get_variants(f_members, 3);

			if (members[i].type == 1 && g_members > 1) {
				g_variants -= get_variants(g_members - 1, 1);
			}
			if (members[i].type == 2 && d_members > 2) {
				d_variants -= get_variants(d_members - 1, 2);
			}
			if (members[i].type == 3 && f_members > 3) {
				f_variants -= get_variants(f_members - 1, 3);
			}

			variants += g_variants * d_variants * f_variants;
		}
	}

	cout << variants;

	return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int g, d, f;

int cntg[100001]; // cntg[i] - kolvo golkeeperov s nomerom <= i
int cntd[100001];
int cntf[100001];

int main () {

    cin >> g >> d >> f;

    vector<pair<int, int> > golly;
    vector<pair<int, int> > defender;
    vector<pair<int, int> > forward;
    vector<pair<int, int> > players;

    int x = 0;

    for (int i = 0; i<g; i++) {
        cin >> x;
        golly.push_back(make_pair(x, 1));
        players.push_back(make_pair(x, 1));
    }

    sort(golly.begin(), golly.end());

    for (int i = 0; i<d; i++) {
        cin >> x;
        defender.push_back(make_pair(x, 2));
        players.push_back(make_pair(x, 2));
    }

    sort(defender.begin(), defender.end());

    for (int i = 0; i<f; i++) {
        cin >> x;
        forward.push_back(make_pair(x, 3));
        players.push_back(make_pair(x, 3));
    }

    sort(forward.begin(), forward.end());

    sort(players.begin(), players.end());

    int curindg= 0;
    int curindf= 0;
    int curindd= 0;

    for (int i = 1; i<=100000; i++) {
        cntf[i] = cntf[i-1];
        cntd[i] = cntd[i-1];
        cntg[i] = cntg[i-1];
        if (curindg<g && golly[curindg].first==i)
        {
            cntg[i]++;
            curindg++;
        }
        if (curindd < d && defender[curindd].first==i) {
            cntd[i]++;
            curindd++;
        }

        if (curindf < f && forward[curindf].first==i) {
            cntf[i]++;
            curindf++;
        }
    }

    long long players_num = players.size();

    long long ans = 0;

    // 1 golly + 2 def + 3 forward
    for (long long i = 0; i<players_num; i++) {
        int cur_player = players[i].second;
        int cur_number = players[i].first;

        int l = cur_number;
        int r = 2*cur_number;

        if (cur_player==1) {
            long long cnt = cntd[r] - cntd[l];
            long long cnt2 = cntf[r] - cntf[l];
            ans += (long long)cnt*(cnt-1)/2 * (long long)cnt2*(cnt2-1)*(cnt2-2)/6;

        }
        else if (cur_player==2) {
            long long cnt = cntg[r] - cntg[l];
            long long cnt2 = cntd[r] - cntd[l];
            long long cnt3 = cntf[r] - cntf[l];
            ans += (long long)cnt * (long long)cnt2 * (long long)cnt3*(cnt3-1)*(cnt3-2)/6;

        }
        else {
            long long cnt = cntg[r] - cntg[l];
            long long cnt2 = cntd[r] - cntd[l];
            long long cnt3 = cntf[r] - cntf[l];
            ans += (long long)cnt * (long long)cnt2*(cnt2-1)/2 * (long long)cnt3*(cnt3-1)/2;

        }
    }

    cout << ans;

}


#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int g, d, f;

int cntg[100001]; // cntg[i] - kolvo golkeeperov s nomerom <= i
int cntd[100001];
int cntf[100001];

int main () {

    cin >> g >> d >> f;

    vector<pair<int, int> > golly;
    vector<pair<int, int> > defender;
    vector<pair<int, int> > forward;
    vector<pair<int, int> > players;

    int x = 0;

    for (int i = 0; i<g; i++) {
        cin >> x;
        golly.push_back(make_pair(x, 1));
        players.push_back(make_pair(x, 1));
    }

    sort(golly.begin(), golly.end());

    for (int i = 0; i<d; i++) {
        cin >> x;
        defender.push_back(make_pair(x, 2));
        players.push_back(make_pair(x, 2));
    }

    sort(defender.begin(), defender.end());

    for (int i = 0; i<f; i++) {
        cin >> x;
        forward.push_back(make_pair(x, 3));
        players.push_back(make_pair(x, 3));
    }

    sort(forward.begin(), forward.end());

    sort(players.begin(), players.end());

    int curindg= 0;
    int curindf= 0;
    int curindd= 0;

    for (int i = 1; i<=100000; i++) {
        cntf[i] = cntf[i-1];
        cntd[i] = cntd[i-1];
        cntg[i] = cntg[i-1];
        if (curindg<g && golly[curindg].first==i)
        {
            cntg[i]++;
            curindg++;
        }
        if (curindd < d && defender[curindd].first==i) {
            cntd[i]++;
            curindd++;
        }

        if (curindf < f && forward[curindf].first==i) {
            cntf[i]++;
            curindf++;
        }
    }

    long long players_num = players.size();

    long long ans = 0;

    // 1 golly + 2 def + 3 forward
    for (long long i = 0; i<players_num; i++) {
        int cur_player = players[i].second;
        int cur_number = players[i].first;

        int l = cur_number;
        int r = 2*cur_number;
        if (r>100000) r = 100000;

        if (cur_player==1) {

            long long cnt = cntd[r] - cntd[l];
            long long cnt2 = cntf[r] - cntf[l];
            ans += (long long)cnt*(cnt-1)/2 * (long long)cnt2*(cnt2-1)*(cnt2-2)/6;

        }
        else if (cur_player==2) {
            long long cnt = cntg[r] - cntg[l];
            long long cnt2 = cntd[r] - cntd[l];
            long long cnt3 = cntf[r] - cntf[l];
            ans += (long long)cnt * (long long)cnt2 * (long long)cnt3*(cnt3-1)*(cnt3-2)/6;

        }
        else {
            long long cnt = cntg[r] - cntg[l];
            long long cnt2 = cntd[r] - cntd[l];
            long long cnt3 = cntf[r] - cntf[l];
            ans += (long long)cnt * (long long)cnt2*(cnt2-1)/2 * (long long)cnt3*(cnt3-1)/2;

        }
    }

    cout << ans;

}


#include <stdio.h>
#include <vector>
#include <algorithm>

typedef long long ll;
#define nmax	100009

ll comb[1111][4];

void C(){

	for(int i = 0; i < 1100; ++i)
		comb[i][0] = 1;

	for(int i = 1; i < 1100; ++i){
		for(int j = 1; j <= 3; ++j){
			comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}
}

std::vector< std::pair<int, int> > v;

bool cmp(std::pair<int, int> a, std::pair<int, int> b){
	return a.first < b.first;
}

int main(){
	C();

	int G, D, F; scanf("%d %d %d", &G, &D, &F);

	for(int i = 0; i < G; ++i){
		int x; scanf("%d", &x);
		v.push_back({x, 1});
	}

	for(int i = 0; i < D; ++i){
		int x; scanf("%d", &x);
		v.push_back({x, 2});
	}

	for(int i = 0; i < F; ++i){
		int x; scanf("%d", &x);
		v.push_back({x, 3});
	}

	int cnt[] = {0, 0, 0, 0};

	std::sort(v.begin(), v.end(), cmp);

	int i = 0, j = 0, N = G + D + F;

	ll ans = 0;

	while(i < N){

		while(j < N && 2 * v[i].first >= v[j].first){
			cnt[v[j].second]++;
			j++;
		}

		ll tmp = 1;
		for(int k = 1; k <= 3; ++k)
			tmp *= comb[cnt[k]][k];

		ans += tmp;

		cnt[v[i].second]--;
		i++;
	}

	printf("%I64d", ans);

return 0;
}


#include <stdio.h>
#include <vector>
#include <algorithm>

typedef long long ll;
#define nmax	100009

ll comb[1111][4];

void C(){

	for(int i = 0; i < 1100; ++i)
		comb[i][0] = 1;

	for(int i = 1; i < 1100; ++i){
		for(int j = 1; j <= 3; ++j){
			comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
		}
	}
}

std::vector< std::pair<int, int> > v;

bool cmp(std::pair<int, int> a, std::pair<int, int> b){
	return a.first < b.first;
}

int main(){
	C();

	int G, D, F; scanf("%d %d %d", &G, &D, &F);

	for(int i = 0; i < G; ++i){
		int x; scanf("%d", &x);
		v.push_back({x, 1});
	}

	for(int i = 0; i < D; ++i){
		int x; scanf("%d", &x);
		v.push_back({x, 2});
	}

	for(int i = 0; i < F; ++i){
		int x; scanf("%d", &x);
		v.push_back({x, 3});
	}

	int cnt[] = {0, 0, 0, 0};
	int cntp[] = {0, 0, 0, 0};

	std::sort(v.begin(), v.end(), cmp);

	int i = 0, j = 0, N = G + D + F;

	ll ans = 0;

	while(i < N){
		for(int k = 1; k <= 3; ++k)
			cntp[k] = cnt[k];

		while(j < N && 2 * v[i].first >= v[j].first){
			cnt[v[j].second]++;
			j++;
		}

		ll tmp = 1;
		for(int k = 1; k <= 3; ++k)
			tmp *= comb[cnt[k]][k];

		ll tmpp = 1;
		for(int k = 1; k <= 3; ++k)
			tmpp *= comb[cntp[k]][k];

		ans += tmp;
		ans -= tmpp;

		cnt[v[i].second]--;
		i++;
	}

	//printf("%lld", ans);
	printf("%I64d", ans);

return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define sz(a) int(a.size())

typedef long long ll;

const int N = 1e6 + 9;

char type[N];
vector<ll> a;

ll soch(ll n, ll k) {
        if (k == 0)
                return 1;
        if (k == 1)
                return n;
        if (k == 2)
                return n*(n - 1)/2;
        if (k == 3)
                return n*(n - 1)*(n - 2)/6;
}

int main() {
	ios::sync_with_stdio(0);
	int n, m, k;
	ll x, ans = 0;
	cin >> n >> m >> k;
	forn(i, n) {
		cin >> x;
		a.pb(x);
		type[x] = 'g';
	}
	forn(i, m) {
		cin >> x;
		a.pb(x);
		type[x] = 'p';
	}
	forn(i, k) {
		cin >> x;
		a.pb(x);
		type[x] = 'a';
	}
	sort(a.begin(), a.end());
        for (int i = 1; i < sz(a); i++) {
                ll g = 0, at = 0, p = 0, ng, np, na;
                for (int j = i - 1; j >= 0 && a[i] / 2 + a[i] % 2 <= a[j]; j--) {
                        ng = 1, np = 2, na = 3;
                        if (type[a[i]] == 'g')
                                ng--;
                        if (type[a[i]] == 'a')
                                na--;
                        if (type[a[i]] == 'p')
                                np--;
                        if (type[a[j]] == 'g')
                                ng--;
                        if (type[a[j]] == 'a')
                                na--;
                        if (type[a[j]] == 'p')
                                np--;
                        if (ng < 0)
                                continue;
                        ans += soch(at, na) * soch(g, ng) * soch(p, np);
                        if (type[a[j]] == 'g')
                                g++;
                        if (type[a[j]] == 'a')
                                at++;
                        if (type[a[j]] == 'p')
                                p++;

                }
        }
        cout << ans;
	return 0;

}


//
//  Created by Ruslan Jankurazov.
//  Copyright © 2018 Ruslan Jankurazov. All rights reserved.
//

#pragma GCC optimize("Ofast")

#include "bits/stdc++.h"

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define f first
#define s second
#define uint unsigned int

using namespace std;

int q[2000];
int w[2000];
int d[2000];

int main() {
#define FILE_INPUT 0
#define FILE ""
#ifndef DEBUG
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#if FILE_INPUT == 1
#warning "FREOPEN is on"
    freopen(FILE".in", "r", stdin);
    freopen(FILE".out", "w", stdout);
#endif
#endif
    int a, b, c;
    cin >> a >> b >> c;
    vector <int> v;
    for (int i = 1; i <= a; ++i) {
        cin >> q[i];
        v.pb(q[i]);
    }
    for (int i = 1; i <= b; ++i) {
        cin >> w[i];
        v.pb(w[i]);
    }
    for (int i = 1; i <= c; ++i) {
        cin >> d[i];
        v.pb(d[i]);
    }
    sort(q + 1, q + a + 1);
    sort(w + 1, w + b + 1);
    sort(d + 1, d + c + 1);
    sort(v.begin(), v.end());
    ll ans = 0;
    for (int i = 1; i <= a; ++i) {
        ll cnt2 = 0;
        for (int j = 1; j <= b; ++j) {
            if (w[j] >= q[i] && w[j] <= q[i]*2) {
                cnt2++;
            }
        }

        ll cnt3 = 0;
        for (int j = 1; j <= c; ++j) {
            if (d[j] >= q[i] && d[j] <= q[i]*2) {
                cnt3++;
            }
        }

        ans += (cnt2*(cnt2 - 1)/2) * (cnt3*(cnt3 - 1)*(cnt3 - 2)/6);
    }
    for (int i = 1; i <= b; ++i) {
        ll cnt1 = 0;
        for (int j = 1; j <= a; ++j) {
            if (q[j] >= w[i] && q[j] <= w[i]*2) {
                cnt1++;
            }
        }
        ll cnt2 = 0;
        for (int j = 1; j <= b; ++j) {
            if (w[j] > w[i] && w[j] <= w[i]*2) {
                cnt2++;
            }
        }
        ll cnt3 = 0;
        for (int j = 1; j <= c; ++j) {
            if (d[j] >= w[i] && d[j] <= w[i]*2) {
                cnt3++;
            }
        }
        ans += cnt1*cnt2*(cnt3*(cnt3 - 1)*(cnt3 - 2)/6);
    }
    for (int i = 1; i <= c; ++i) {
        ll cnt1 = 0;
        for (int j = 1; j <= a; ++j) {
            if (q[j] >= d[i] && q[j] <= d[i]*2) {
                cnt1++;
            }
        }
        ll cnt2 = 0;
        for (int j = 1; j <= b; ++j) {
            if (w[j] >= d[i] && w[j] <= d[i]*2) {
                cnt2++;
            }
        }
        ll cnt3 = 0;
        for (int j = 1; j <= c; ++j) {
            if (d[j] > d[i] && d[j] <= d[i]*2) {
                cnt3++;
            }
        }
        ans += cnt1*(cnt2*(cnt2 - 1)/2)*(cnt3*(cnt3 - 1)/2);
    }
    cout << ans;
    return 0;
}