a,b,c,d,e,f;main(i){for(;~scanf("%d",&f);i++%3?d=e,e=f:i-7?a=d+e,b=d+f,c=e+f,d=e=f=0:printf("%d",a*f+b*e+c*d<<1))e>f?f^=e^=f^=e:0,d>e?d^=e^=d^=e:0;}