import java.util.*; class Main{ static int max(int x, int y){ return x > y ? x : y; } public static void main(String[] args){ Scanner sc = new Scanner(System.in); int M = 5000; int n = Integer.parseInt(sc.next()); int Rcnt[] = new int[M + 1]; int Gcnt[] = new int[M + 1]; int Bcnt[] = new int[M + 1]; int x; for (int i = 0; i < n; i++){ x = Integer.parseInt(sc.next()); Rcnt[x]++; } for (int i = 0; i < n; i++){ x = Integer.parseInt(sc.next()); Gcnt[x]++; } for (int i = 0; i < n; i++){ x = Integer.parseInt(sc.next()); Bcnt[x]++; } long C[][] = new long[M + 2][2 * M + 2]; for (int i = 1; i <= M; i++){ if (Gcnt[i] == 0) continue; for (int j = 1; j <= M; j++){ C[max(i, j) + 1][i + j + 1] += (long)Gcnt[i] * Bcnt[j]; } } for (int i = 0; i < M + 1; i++){ for (int j = 0; j < 2 * M + 1; j++){ C[i + 1][j + 1] += C[i][j + 1] + C[i + 1][j] - C[i][j]; } } long ans = 0; for (int i = 1; i <= M; i++){ long tmp = C[i + 1][2 * M + 1] + C[1][i + 1] - C[i + 1][i + 1] - C[1][2 * M + 1]; ans += (long)Rcnt[i] * tmp; } System.out.println(ans); } }