#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"from itertools import*\n"
"n,a,b,c,*l=map(int,open(0).read().split())\n"
"a=a,b,c\n"
"m=10**18\n"
"for s in product(*[range(4)]*n):\n"
"  if all(i in s for i in(0,1,2)):\n"
"    t,c=[0]*4,[0]*4\n"
"    for i,v in zip(s,l):\n"
"      t[i]+=v\n"
"      c[i]+=1\n"
"    m=min(m,sum(abs(x-y)+~-z*10for x,y,z in zip(a,t,c)))\n"
"print(m)\n"
"\"";
  system(s);
  return 0;
}            