#include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using uint = unsigned; using ull = unsigned long long; using namespace std; template constexpr T INF = ::numeric_limits::max() / 32 * 15 + 208; int main() { int n; cin >> n; int m = 3000; vector r(m+1), g(m+1), b(m+1); for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); r[x]++; } for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); g[x]++; } for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); b[x]++; } for (int i = 0; i < m; ++i) { b[i+1] += b[i]; } ll ans = 0; for (int i = 0; i <= m; ++i) { for (int j = 0; j <= i; ++j) { ans += r[i]*g[j]*(b[i]-b[i-j]); } } cout << ans << "\n"; return 0; }