#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define int long long int r[200020], g[200020], b[200020]; int co1[3030], co2[3030], co3[3030]; int sum[3030][6060] = {}; signed main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> r[i]; co1[r[i]]++; } sort(r, r + n); for (int i = 0; i < n; i++) { cin >> g[i]; co2[g[i]]++; } sort(g, g + n); for (int i = 0; i < n; i++) { cin >> b[i]; co3[b[i]]++; } sort(b, b + n); for (int i = 1; i <= 3000; i++) { for (int j = 1; j <= 3000; j++) { sum[max(i, j)][i + j] += co2[i] * co3[j]; } } for (int i = 1; i <= 3000; i++) { for (int j = 2; j <= 3000; j++) { sum[i][j] += sum[i][j - 1]; } } long long ans = 0; for (int i = 1; i <= 3000; i++) { for (int j = 1; j <= i; j++) { ans += co1[i] * (sum[j][3000] - sum[j][i]); } } cout << ans << endl; }