#include using namespace std; int t[3][3010] = {}; int main() { /* for(int i = 0; i < 3; ++i) { for(int j = 0; j < 3000; ++j) { cout << i << ',' << j << '\n'; if(t[i][j]) cerr << "err!\n"; } }*/ int n; cin >> n; for(int i = 0; i < 3; ++i) { for(int j = 0; j < n; ++j) { int a; cin >> a; ++t[i][a]; } } for(int i = 1; i <= 3000; ++i) { t[2][i] += t[2][i-1]; } long long count = 0; for(int r = 1; r <= 3000; ++r) { for(int g = 1; g <= r; ++g) { count += t[0][r]*t[1][g]*(t[2][r]-t[2][min(r-g, r)]); } } cout << count << '\n'; }