mod = 1000000007 eps = 10**-9 M = 3*10**3 def main(): import sys input = sys.stdin.readline N = int(input()) R = list(map(int, input().split())) G = list(map(int, input().split())) B = list(map(int, input().split())) RR = [0] * (M+1) GG = [0] * (M+1) BB = [0] * (M+1) for i in range(N): RR[R[i]] += 1 GG[G[i]] += 1 BB[B[i]] += 1 ans = 0 cs_RR = [0] * (M+2) for i in range(M+1): cs_RR[i+1] = cs_RR[i] + RR[i] for i in range(M+1): for j in range(M+1): gb = GG[i] * BB[j] ans += gb * (cs_RR[min(M, i+j-1) + 1] - cs_RR[max(i, j)]) print(ans) #print(RR) #print(GG) #print(BB) #print(cs_RR) if __name__ == '__main__': main()