#include #include #include #include #include #include #include int cmpr(const void *a,const void *b) { return *(char *)a-*(char * )b; } int main(){ int n, sum = 0; scanf("%d",&n); int *calories = malloc(sizeof(int) * n); for(int calories_i = 0; calories_i < n; calories_i++){ scanf("%d",&calories[calories_i]); //sum += calories[calories_i] } qsort(calories, n, sizeof(int), cmpr); for(int i = n - 1, j = 0; i > -1; i--) { sum += calories[i] * pow(2, j++); } printf("%d", sum); return 0; }