void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.typecons;

  int n; rd(n);
  auto data=new int[][](3, 0);
  foreach(i; 0..3) data[i]=readln.split.to!(int[]);

  auto a=new Tuple!(int, int)[](0);
  foreach(i; 0..3){
    foreach(e; data[i]) a~=Tuple!(int, int)(e, i);
  }
  sort(a);
  // writeln(a);
  alias P=Tuple!(int, int, int);
  auto b=new P[](0);
  for(auto i=0; i<a.length;){
    auto e=a[i];
    int[3] cnt;
    foreach(j; 0..3){
      while(i<a.length && e[0]==a[i][0] && j==a[i][1]) cnt[j]++, i++; 
    }
    b~=P(cnt[0], cnt[1], cnt[2]);
  }
  // writeln(b);
  int x=0, y=0, z=0;
  foreach(e; b){
    z+=y*e[2];
    y+=x*e[1];
    x+=e[0];
  }
  writeln(z);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}