//2015
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
int main(void){
	int i,ad[4]={0},e=0,f=0,sum=0;
	for(i=0;i<4;i++){
		cin>>ad[i];
	}
	cin>>e;
	cin>>f;
	sort(ad,ad+4,greater<int>());//降順,昇順＝＝sort(ad,ad+4);
	for(i=0;i<3;i++){
		sum+=ad[i];
	}
	if(e<f){
		sum+=f;
	}
	else{
		sum+=e;
	}
	cout<<sum<<endl;
	return 0;
}

/**
 *		author:  zvm
 *		created: 25.09.2020 13:51:29
**/

#include <bits/stdc++.h>

using namespace std ;

typedef long long int ll ;
const ll INF = 1e18 ;

int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);	

	int n ;
	cin >> n ;

	vector<int> a(n), b(n), c(n);

	for( int i = 0 ; i < n ; ++i ) {
		cin >> a[i] ;
	}
	for( int i = 0 ; i < n ; ++i ) {
		cin >> b[i] ;
	}
	for( int i = 0 ; i < n ; ++i ) {
		cin >> c[i] ;
	}

	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	sort(c.begin(),c.end());

	vector<pair<int,ll>> good(n);
	for( int i = 0 ; i < n ; ++i ) {
		good[i].first = b[i] ;
		good[i].second = c.end() - upper_bound(c.begin(),c.end(),b[i]) ;
	}

	for( int i = n-2 ; i >= 0 ; --i ) {
		good[i].second += good[i+1].second ;
	}

	ll ans = 0 ;
	for( int i = 0 ; i < n ; ++i ) {
		pair<int,ll> to_find{a[i],INF};
		auto pos = upper_bound(good.begin(),good.end(),to_find) ;
		if( pos != good.end() ) {
			ans += (*pos).second ;
		}
	}
	
	cout << ans << endl ;
}
