#!/bin/python3

import math
import os
import random
import re
import sys

arr = list(map(int, input().rstrip().split()))

one = arr[0]+ arr[1] + arr[2] + arr[3]
two = arr[1]+ arr[2] + arr[3] + arr[4]
three = arr[2]+ arr[3] + arr[4] + arr[0]
four = arr[3]+ arr[4] + arr[0] + arr[1]
five = arr[4]+ arr[0] + arr[1] + arr[2]
arr1 = [one,  two, three, four, five]
ma = arr1[0]
mi =arr1[0]
for i  in  range(1,5):
    if  arr1[i] >  ma:
        ma = arr1[i]
    if arr1[i]<mi:
        mi = arr1[i]
print (mi, ma)

    



