#define _USE_MATH_DEFINES #include //cin, cout #include //vector #include //sort,min,max,count #include //string,getline, to_string #include //abs(int) #include //swap, pair #include //deque #include //INT_MAX #include //bitset #include //sqrt, ceil. M_PI, pow, sin #include //fixed #include //setprecision #include //stringstream #include //gcd, assumlate #include //randam_device #include //numeric_limits using namespace std; constexpr long long int D_MOD = 1000000007; int main() { vector A(3); int B; cin >> A[0] >> A[1] >> A[2] >> B; int max = 0; int temp; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { temp = A[i] + A[j] + A[k]; if (i == 0 && j == 1 && k == 2) { temp += B; } if (max < temp) { max = temp; } } } } cout << max << endl; return 0; }