#include /* #include #include namespace mp = boost::multiprecision; using bint = mp::cpp_int; */ #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for (int i = 0; i < int(n); ++i) #define repp(i,n,m) for (int i = m; i < int(n); ++i) #define repb(i,n) for (int i = int(n)-1; i >= 0; --i) #define fi first #define se second using namespace std; using namespace atcoder; using namespace internal; using ll = long long; using ld = long double; using P = pair; using PL = pair; using Pxy = pair; const int INF = 1001001007; const long long mod1 = 1000000007LL; const long long mod2 = 998244353LL; const ll inf = 2e18; const ld pi = 3.14159265358979323; templatevoid priv(vector &v){if(v.size()==0){cout<void privv(vector> &v){rep(i,v.size()){rep(j,v[i].size()-1)cout<bool range(T a,T b,T x){return (a<=x&&xbool rrange(pair a,pair b,pair x){return range(a.fi,b.fi,x.fi)&&range(a.se,b.se,x.se);} templatevoid rev(vector &v){reverse(v.begin(),v.end());} templatevoid sor(vector &v, int f=0){sort(v.begin(),v.end());if(f!=0) rev(v);} templatebool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;} templatebool chmax(T &a,const T &b){if(avoid eru(vector &v){sor(v);v.erase(unique(v.begin(),v.end()),v.end());} templateT cel(T a,T b){if (a%b==0)return a/b;return a/b +1;} template void pout(pair p){cout<void myswap(T &a,T &b){if(a>b)swap(a,b);} void yes(){cout << "Yes" << endl;} void no (){cout << "No" << endl;} void yn (bool t){if(t)yes();else no();} void Yes(){cout << "YES" << endl;} void No (){cout << "NO" << endl;} void YN (bool t){if(t)Yes();else No();} void dout() {cout << setprecision(20);} void deb(ll h = INF-1) {cout << (h == INF-1 ? "!?" : to_string(h)) << endl;} void revs(string &s) {reverse(s.begin(),s.end());} vector dx = {0,1,0,-1}; vector dy = {1,0,-1,0}; const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const string alp = "abcdefghijklmnopqrstuvwxyz"; const string num = "0123456789"; ll gcds(ll a, ll b){ a = abs(a); b = abs(b); if (b == 0) return a; ll c = a % b; while (c != 0){ a = b; b = c; c = a % b; } return b; } ll tentou(vector ar){ int n = ar.size(); set st; rep(i,n) st.insert(ar[i]); map mp; int ind = 0; for (ll x : st){ mp[x] = ind; ind++; } fenwick_tree fw(ind); ll ans = 0; rep(i,n){ int a = mp[ar[i]]; ans += i - fw.sum(0,a+1); fw.add(a,1); } return ans; } struct vs{ vector to; vector cost; }; /* alias g++='g++ -I/mnt/c/Users/Owner/Desktop/ac-library' */ int main(){ int n; cin >> n; vector a(3010,0); vector b(3010,0); vector c(3010,0); rep(i,n){int x; cin >> x; a[x]++;} rep(i,n){int x; cin >> x; b[x]++;} rep(i,n){int x; cin >> x; c[x]++;} ll ans = 0; vector dp(6020,0); repp(i,3010,1){ repp(j,i,1) dp[i+j] += c[i] * b[j]; repp(j,i,1) dp[i+j] += b[i] * c[j]; dp[i+i] += b[i] * c[i]; repp(j,i+i+1,i+1) ans += a[i] * dp[j]; } cout << ans << endl; }