#include <stdio.h>
#include <stdlib.h>
int compare (const void* a, const void* b){
return (*(int*)a-*(int*)b);
}
int main(void) {
int c, n, s[100], i, r;
while(c--){
for(i=0;i<n;i++)
i=r=0;
while(i<n-1){
qsort (s
, n
, 4, compare
); s[i+1] = s[i]+s[i+1];
r+=s[++i];
}
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KaW50IGNvbXBhcmUgKGNvbnN0IHZvaWQqIGEsIGNvbnN0IHZvaWQqIGIpewogIHJldHVybiAoKihpbnQqKWEtKihpbnQqKWIpOwp9CmludCBtYWluKHZvaWQpIHsKCWludCBjLCBuLCBzWzEwMF0sIGksIHI7CglzY2FuZigiJWQiLCZjKTsKCXdoaWxlKGMtLSl7CgkJc2NhbmYoIiVkIiwmbik7CgkJZm9yKGk9MDtpPG47aSsrKQoJCQlzY2FuZigiJWQiLHMraSk7CgkJaT1yPTA7CgkJd2hpbGUoaTxuLTEpewoJCQlxc29ydCAocywgbiwgNCwgY29tcGFyZSk7CgkJCXNbaSsxXSA9IHNbaV0rc1tpKzFdOwoJCQlyKz1zWysraV07CgkJfQoJCXByaW50ZigiJWRcbiIscik7Cgl9CglyZXR1cm4gMDsKfQ==