typedef long long ll; typedef long double ld; #include using namespace std; #define int long long signed main(){ cin.tie(0); ios::sync_with_stdio(false); ll n; std::cin >> n; map cnt1,cnt2,cnt3; for (int i = 0; i < n; i++) { ll a; std::cin >> a; cnt1[a]++; } for (int i = 0; i < n; i++) { ll a; std::cin >> a; cnt2[a]++; } for (int i = 0; i < n; i++) { ll a; std::cin >> a; cnt3[a]++; } vector> dp(6001,vector(3001)); for (int i = 0; i <= 6000; i++) { for (int j = 0; j <= i; j++) { dp[i][max(j,i-j)] += cnt2[i-j]*cnt3[j]; } } vector ruic(3001); for (int i = 1; i <= 3000; i++) { ruic[i] = ruic[i-1]+cnt1[i]; } ll ans = 0; for (int i = 0; i <= 6000; i++) { for (int j = 0; j <= i; j++) { ans += max(0ll,(ruic[i-1]-ruic[j-1]))*dp[i][j]; // if((ruic[i-1]-ruic[j-1]>0*dp[i][j]>0){ // std::cout << i<<" "<