#include #include #include #include using namespace std; using ll = long long; int main(){ int n; cin >> n; vector r(n), g(n), b(n); for(auto &it: r) cin >> it; for(auto &it: g) cin >> it; for(auto &it: b) cin >> it; vector rcnt(3010, 0), gcnt(3010, 0), bcnt(3010, 0); for(auto &it: r) rcnt[it]++; for(auto &it: g) gcnt[it]++; for(auto &it: b) bcnt[it]++; vector btot(3020, 0); for(int i = 0; i < 3010; i++) btot[i+1] = btot[i]+bcnt[i]; ll ans = 0; for(int i = 1; i < 3010; i++){ if(rcnt[i] == 0) continue; for(int j = 1; j <= i; j++){ if(gcnt[j] == 0) continue; ans += 1LL*rcnt[i]*gcnt[j]*(btot[i+1]-btot[i-j+1]); } } cout << ans << endl; return 0; }