#include int main() { int i, n, x, num[3][3001] = {}; scanf("%d", &n); for (i = 1; i <= n; i++) { scanf("%d", &x); num[0][x]++; } for (i = 1; i <= n; i++) { scanf("%d", &x); num[1][x]++; } for (i = 1; i <= n; i++) { scanf("%d", &x); num[2][x]++; } int j, k, l; long long count[3002][3002] = {}, ans = 0; for (i = 1; i <= 3000; i++) { for (j = 1; j <= 3000; j++) { k = i + j - 1; if (k > 3000) k = 3000; l = (i >= j)? i: j; count[k][l] += (long long)num[1][i] * num[2][j]; } } for (i = 3000; i >= 1; i--) for (j = 1; j <= 3000; j++) count[i][j] += count[i+1][j] + count[i][j-1] - count[i+1][j-1]; for (i = 1; i <= 3000; i++) ans += count[i][i] * num[0][i]; printf("%lld\n", ans); fflush(stdout); return 0; }