#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int main() { ll N; cin >> N; vector R(N); vector G(N); vector B(N); map r_counter; map g_counter; map b_counter; for (int i = 0; i < N; ++i) { cin >> R[i]; r_counter[R[i]]++; } for (int i = 0; i < N; ++i) { cin >> G[i]; g_counter[G[i]]++; } for (int i = 0; i < N; ++i) { cin >> B[i]; b_counter[B[i]]++; } sort(R.begin(), R.end()); sort(G.begin(), G.end()); sort(B.begin(), B.end()); ll ans = N * N * N; ll dp[6010]; memset(dp, 0, sizeof(dp)); for (int i = 0; i < N; ++i) { int r = R[i]; ll c1 = N - (ll) (lower_bound(G.begin(), G.end(), r + 1) - G.begin()); ll c2 = N - (ll) (lower_bound(B.begin(), B.end(), r + 1) - B.begin()); // fprintf(stderr, "c1: %lld, c2: %lld\n", c1, c2); ans -= c1 * N; ans -= c2 * N; ans += c1 * c2; } for (int v = 1; v <= 3000; ++v) { for (int w = 1; w <= 3000; ++w) { dp[v + w] += g_counter[v] * b_counter[w]; } } for (int v = 1; v <= 3000; ++v) { if (r_counter[v] == 0) continue; for (int w = 1; w <= v; ++w) { if (dp[w] == 0) continue; ans -= r_counter[v] * dp[w]; } } cout << ans << endl; return 0; }