#include using namespace std; #define rep(i, l, r) for (auto i = (l); i < (r); i++) using ll = int; int main() { int n; cin >> n; vector r(n); vector g(n); vector b(n); rep(i, 0, n) cin >> r[i]; rep(i, 0, n) cin >> g[i]; rep(i, 0, n) cin >> b[i]; vector R(3001, 0); vector G(3001, 0); vector B(3001, 0); rep(i, 0, n) { R[r[i]]++; G[g[i]]++; B[b[i]]++; } vector imos(3003, 0); rep(green, 0, 3001) rep(blue, 0, 3001) { int r = green + blue; int l = max(green, blue); ll count = G[green] * B[blue]; imos[l] += count; imos[r] -= count; } rep(i, 0, 3000) imos[i + 1] += imos[i]; ll ans = 0; rep(red, 0, 3001) ans += R[red] * imos[red]; cout << ans << endl; return 0; }