#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int MAX_L = 3000; ll R[MAX_L + 1] = {}, G[MAX_L + 1] = {}, B[MAX_L + 1] = {}; int n; cin >> n; rep(_,n) { int x; cin >> x; R[x]++; } rep(_,n) { int x; cin >> x; G[x]++; } rep(_,n) { int x; cin >> x; B[x]++; } ll sumR[MAX_L + 2] = {}; for(int i = 0; i <= MAX_L; i++) sumR[i + 1] += sumR[i] + R[i]; // max(g,b) <= r < g+b ll ans = 0; for(int g = 1; g <= MAX_L; g++) { for(int b = 1; b <= MAX_L; b++) { ans += (sumR[min(g + b, MAX_L + 1)] - sumR[max(g, b)]) * G[g] * B[b]; } } cout << ans << endl; }