#include namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n[3]; rep(i, 3) cin >> n[i]; constexpr int B = 3010; static int cnt[3][2 * B + 1]; static int cacc[3][2 * B + 2]; static ll s[3][2 * B + 2]; rep(i, 3) { rep(j, n[i]) { int x; cin >> x; cnt[i][B + x]++; } rep(j, 2 * B + 1) { cacc[i][j + 1] = cacc[i][j] + cnt[i][j]; s[i][j + 1] = s[i][j] + cnt[i][j] * (j - B); } } ll ans = 0; constexpr int INF = 1001001001; for (int v0 = -B; v0 <= B + 1; v0++) for (int v2 = -B; v2 <= B + 1; v2++) { ll s0 = s[0][B + B + 1] - s[0][B + v0]; int c0 = cacc[0][B + B + 1] - cacc[0][B + v0]; ll s2 = s[2][B + B + 1] - s[2][B + v2]; int c2 = cacc[2][B + B + 1] - cacc[2][B + v2]; auto flr = [&](ll x, int y) { if (x >= 0) return x / y; else return -((-x + y - 1) / y); }; ll v1_ll = [&]() -> ll { if (c2 == 0) { return s0 > 0 ? -INF : INF; } return flr(-s0, c2); }(); int v1 = clamp(v1_ll, -B, B + 1); ll s1 = s[1][B + B + 1] - s[1][B + v1]; int c1 = cacc[1][B + B + 1] - cacc[1][B + v1]; chmax(ans, s0 * c1 + s1 * c2 + s2 * c0); } cout << ans << '\n'; }