import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    res = dfs(cur + 1, a, b, c)
    res = min(res, dfs(cur + 1, a + l[cur], b, c) + 10)
    res = min(res, dfs(cur + 1, a, b + l[cur], c) + 10)
    res = min(res, dfs(cur + 1, a, b, c + l[cur]) + 10)
    return res
print(dfs(0, 0, 0, 0)) import sys sys import itertools itertools import time time import math math import heapq heapq from collections import defaultdict sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 INF = 10 ** 18 INF 10 ** 18 10 18 MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines N, A, B, C = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split A B C int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input l = [int(input()) for _ in range(N)] l [int(input()) for _ in range(N)] def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    res = dfs(cur + 1, a, b, c)
    res = min(res, dfs(cur + 1, a + l[cur], b, c) + 10)
    res = min(res, dfs(cur + 1, a, b + l[cur], c) + 10)
    res = min(res, dfs(cur + 1, a, b, c + l[cur]) + 10)
    return res dfs if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
     cur == N cur N return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF min(a, b, c) > 0 min(a, b, c) min a b c 0 abs(a - A) + abs(b - B) + abs(c - C) - 30 abs(a - A) + abs(b - B) + abs(c - C) abs(a - A) + abs(b - B) abs(a - A) abs a - A a A abs(b - B) abs b - B b B abs(c - C) abs c - C c C 30 INF res = dfs(cur + 1, a, b, c) res dfs(cur + 1, a, b, c) dfs cur + 1 cur 1 a b c res = min(res, dfs(cur + 1, a + l[cur], b, c) + 10) res min(res, dfs(cur + 1, a + l[cur], b, c) + 10) min res dfs(cur + 1, a + l[cur], b, c) + 10 dfs(cur + 1, a + l[cur], b, c) dfs cur + 1 cur 1 a + l[cur] a l[cur] l cur b c 10 res = min(res, dfs(cur + 1, a, b + l[cur], c) + 10) res min(res, dfs(cur + 1, a, b + l[cur], c) + 10) min res dfs(cur + 1, a, b + l[cur], c) + 10 dfs(cur + 1, a, b + l[cur], c) dfs cur + 1 cur 1 a b + l[cur] b l[cur] l cur c 10 res = min(res, dfs(cur + 1, a, b, c + l[cur]) + 10) res min(res, dfs(cur + 1, a, b, c + l[cur]) + 10) min res dfs(cur + 1, a, b, c + l[cur]) + 10 dfs(cur + 1, a, b, c + l[cur]) dfs cur + 1 cur 1 a b c + l[cur] c l[cur] l cur 10 return res res cur cur a a b b c c print(dfs(0, 0, 0, 0)) print dfs(0, 0, 0, 0) dfs 0 0 0 0 readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline read = sys.stdin.buffer.read sys.stdin.buffer.read read N, A, B, C = map(int, input().split()) map(int, input().split()) N C = map(int, input().split()) map(int, input().split()) C A, B, C = map(int, input().split()) map(int, input().split()) A MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    res = dfs(cur + 1, a, b, c)
    res = min(res, dfs(cur + 1, a + l[cur], b, c) + 10)
    res = min(res, dfs(cur + 1, a, b + l[cur], c) + 10)
    res = min(res, dfs(cur + 1, a, b, c + l[cur]) + 10)
    return res def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    res = dfs(cur + 1, a, b, c)
    res = min(res, dfs(cur + 1, a + l[cur], b, c) + 10)
    res = min(res, dfs(cur + 1, a, b + l[cur], c) + 10)
    res = min(res, dfs(cur + 1, a, b, c + l[cur]) + 10)
    return res dfs INF = 10 ** 18 10 ** 18 INF readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines l = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] l B, C = map(int, input().split()) map(int, input().split()) B
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    res = dfs(cur + 1, a, b, c)
    res = min(res, dfs(cur + 1, a + l[cur], b, c) + 10)
    res = min(res, dfs(cur + 1, a, b + l[cur], c) + 10)
    res = min(res, dfs(cur + 1, a, b, c + l[cur]) + 10)
    return res
print(dfs(0, 0, 0, 0))