import sequtils,strutils,algorithm,math,future,macros template get*():string = stdin.readLine().strip() template `min=`*(x,y:typed):void = x = min(x,y) let V = get().split().map(parseInt).sorted(cmp) # 4 * [1,30] const INF = 1e6.int var ans = INF # 30 * 30 * 30 proc getABCCost() : array[31,array[31,array[31,array[31,int]]]] = for a in 0..30: for b in 0..30: for c in 0..30: for d in 0..30: result[a][b][c][d] = INF for A in 1..30: for B in 1..A: for C in 1..B: var dp = newSeqWith(30+1,INF) # v を ABC で 作るのに掛かるコストの最小値 dp[0] = 0 for v in 0..30-A: if dp[v] != INF: dp[v + A] .min= dp[v] + 1 for v in 0..30-B: if dp[v] != INF: dp[v + B] .min= dp[v] + 1 for v in 0..30-C: if dp[v] != INF: dp[v + C] .min= dp[v] + 1 for v in 0..30: result[A][B][C][v] = dp[v] const ABC = getABCCost() for A in 1..V.max(): for B in 1..A: for C in 1..B: ans .min= V.mapIt(ABC[A][B][C][it]).sum() echo ans