#include <bits/stdc++.h>
using namespace std;
long long n,arr[9],A,B,C;
long long dfs(long long l,long long a,long long b,long long c)
{
	if(l==n)
	{
		long long num;
		num=abs(A-a)+abs(B-b)+abs(C-c);
		if(a==0||b==0||c==0)
			return INT_MAX;
		return num-30;
	}
	long long r1,r2,r3,r4;
	r1=dfs(l+1,a+arr[l+1],b,c)+10;
	r2=dfs(l+1,a,b+arr[l+1],c)+10;
	r3=dfs(l+1,a,b,c+arr[l+1])+10;
	r4=dfs(l+1,a,b,c);
	return min(min(r1,r2),min(r3,r4));
}
int main()
{
	long long i,j;
	scanf("%lld %lld %lld %lld",&n,&A,&B,&C);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&arr[i]);
	}
	printf("%lld",dfs(0,0,0,0));
}