#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int n;  cin >> n;
  vector<long long>a(n);  for(int i=0;i<n;i++)  cin >> a.at(i);
  vector<long long>b(n);  for(int i=0;i<n;i++)  cin >> b.at(i);
  vector<long long>c(n);  for(int i=0;i<n;i++)  cin >> c.at(i);
  sort(a.begin(),a.end());
  sort(c.begin(),c.end());

  long long ans = 0;
  for(int i=0;i<n;i++){
    auto Iter = lower_bound(a.begin(),a.end(),b.at(i));
    long long count_a = Iter - a.begin();

    Iter = upper_bound(c.begin(),c.end(),b.at(i));
    long long count_c = n - (Iter - c.begin());

    ans += count_a * count_c;
  }
  cout << ans << endl;
}
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using Graph = vector<vector<ll>>;

int main(){
  int n,l; cin>>n>>l;
  vector<pair<int, bool> > fla;
  for (size_t i = 0; i < n; i++)
  {
    int tmpfl = l + i;
    if (tmpfl< 0)
    {
      tmpfl *= -1;
      fla.push_back(make_pair(tmpfl , true));
      continue;
    }
    fla.push_back(make_pair(tmpfl , false));
    
  }
  sort(fla.begin(), fla.end());
  
  fla.erase(fla.begin());
  ll ans =0;
  for (auto &&i : fla)
  {
    ans += i.second ? -1 * i.first : i.first ;
  }
  cout << ans << endl;
}