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[0]==b[0] ? a[1]>b[1] : a[0]<b[0]"(a);
  long x=0, y=0, z=0;
  foreach(e; a){
    if(e[1]==0) x++;
    else if(e[1]==1) y+=x;
    else z+=y;
  }
  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));
  }
}
