#include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint32_t n, i, j, k; cin >> n; vector r(n), g(n), b(n); for (i = 0; i != n; ++i) cin >> r[i]; for (j = 0; j != n; ++j) cin >> g[j]; for (k = 0; k != n; ++k) cin >> b[k]; vector count_r(3001, 0), count_g(3001, 0), count_b(3001, 0); for (i = 0; i != n; ++i) ++count_r[r[i]]; for (j = 0; j != n; ++j) ++count_g[g[j]]; for (k = 0; k != n; ++k) ++count_b[b[k]]; uint64_t ans = 0; vector sum_count_b(3001); sum_count_b[0] = 0; for (k = 1; k <= 3000; ++k) sum_count_b[k] = sum_count_b[k - 1] + count_b[k]; for (i = 1; i <= 3000; ++i) for (j = 1; j <= i; ++j) ans += static_cast(count_r[i]) * count_g[j] * (sum_count_b[i] - sum_count_b[i - j]); cout << ans << '\n'; return 0; }