#include <bits/stdc++.h>
using namespace std;

#define ct cout
#define in cin
#define el endl
#define rep(i, N) for (int i = 0; i < N; i++)
#define ol(N) cout << N << endl

int main()
{
	int s1[4], s2[2];

	rep(i, 4){
		in >> s1[i];
	}
	in >> s2[0] >> s2[1];

	sort (s1, s1 + 4);
	reverse(s1, s1 + 4);

	ol(s1[0] + s1[1] + s1[2] + max(s2[0], s2[1]));

	return (0);
}
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int maxof(const int a[]) {
	int i;
	int max = a[0];

	for (i = 1; i < 8; i++) {
		if (a[i] > max) max = a[i];
	}
	return max;
}

int main() {
	int a, b, c, d, e, f;
	int r1, r2, r3,r4,r5, r6, r7, r8;
	cin >> a >> b >> c >> d >> e >> f;
	r1 = a + b + c + e;
	r2 = a + b + c + f;
	r3 = a + b + d + e;
	r4 = a + b + d + f;
	r5 = a + c + d + e;
	r6 = a + c + d + f;
	r7 = b + c + d + e;
	r8 = b + c + d + f;
	int ar[] = { r1, r2, r3,r4,r5, r6, r7, r8 };
	cout << maxof(ar) << endl;
}
