from heapq import heappop, heappush from collections import defaultdict n = int(input()) R = list(map(int, input().split())) G = list(map(int, input().split())) B = list(map(int, input().split())) R_len_cnt = [0 for _ in range(3001)] G_len_cnt = [0 for _ in range(3001)] B_len_cnt = [0 for _ in range(3001)] for i in range(n): R_len_cnt[R[i]] += 1 G_len_cnt[G[i]] += 1 B_len_cnt[B[i]] += 1 accumR_len_cnt = [0 for _ in range(3001)] for i in range(3000): accumR_len_cnt[i + 1] += accumR_len_cnt[i] + R_len_cnt[i + 1] ans = 0 for i in range(1, 3001): if G_len_cnt[i] == 0: continue for j in range(1, 3001): if B_len_cnt[j] == 0: continue ans += G_len_cnt[i] * B_len_cnt[j] * (accumR_len_cnt[min(i + j, 3001) - 1] - accumR_len_cnt[max(i, j) - 1]) print(ans)