n = int(input()) M = 4*10**3+5 R = [0]*M G = [0]*M B = [0]*M for r in map(int,input().split()): R[r] += 1 for g in map(int,input().split()): G[g] += 1 for b in map(int,input().split()): B[b] += 1 GB = [[0]*M for i in range(M)] for i in range(M//2): for j in range(M//2): GB[max(i,j)][i+j] += G[i]*B[j] for i in range(1,M): R[i] += R[i-1] ans = 0 for i in range(M): for j in range(i,M): ans += (R[j-1]-R[i-1])*GB[i][j] print(ans)