import std; int MAX = 3 * 10 ^^ 3; void main(){ int n = readln.chomp.to!int; auto r = readln.split.to!(int[]); auto g = readln.split.to!(int[]); auto b = readln.split.to!(int[]); auto rcount = new ulong[MAX + 1]; auto gcount = new ulong[MAX + 1]; auto bsum = new ulong[MAX + 1]; foreach(v; r){ rcount[v] += 1; } foreach(v; g){ gcount[v] += 1; } foreach(v; b){ bsum[v] += 1; } for(auto i = 1; i <= MAX; i++){ bsum[i] += bsum[i-1]; } auto result = 0UL; for(auto i = 1; i <= MAX; i++){ for(auto j = 1; j <= i; j++){ result += rcount[i] * gcount[j] * (bsum[i] - bsum[i-j]); } } result.writeln; }