#include <iostream>
#include <cstring>

using namespace std;

typedef long long LL;

const int N = 1e5 + 10;
int a[N], b[N], c[N], sa[N], sc[N], s[N]; //sa是用来记录a<b[i]得前缀和，sc是用来记录c>b[i]的前缀和，s是临时数组。

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i], a[i]++; //++操作是为了防止输入为0，a[i]++使得s[a[i]]++不可能为0，使得s[i]+=s[i-1]可以计算，又因为且所有增大相当于所有不增大。
    for (int i = 0; i < n; i++)
        cin >> b[i], b[i]++;
    for (int i = 0; i < n; i++)
        cin >> c[i], c[i]++;

    for (int i = 0; i < n; i++)
        s[a[i]]++; //a[i]出现数字的次数被统计。
    for (int i = 1; i < N; i++)
        s[i] += s[i - 1]; //1到i为止的出现的总次数
    for (int i = 0; i < n; i++)
        sa[i] = s[b[i] - 1]; //1-b[i]的从次数

    memset(s, 0, sizeof s);

    for (int i = 0; i < n; i++)
        s[c[i]]++;
    for (int i = 1; i < N; i++)
        s[i] += s[i - 1];
    for (int i = 0; i < n; i++)
        sc[i] = s[N - 1] - s[b[i]]; //n到b[i]的总次数

    LL res = 0;
    for (int i = 0; i <= n; i++)
        res += (LL)sa[i] * sc[i];
    cout << res;
}
