#include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
int n;
int arr[1001];
int result[1001];
int sum;
cin >> n;
for (int i = 0; i < n; i++) cin >> arr[i];
sort(arr, arr + n);
sum = result[0] = arr[0];
for (int i = 1; i < n; i++)
{
result[i] = result[i - 1] + arr[i];
sum += result[i];
}
cout << sum;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKHZvaWQpCnsKCWludCBuOwoJaW50IGFyclsxMDAxXTsKCWludCByZXN1bHRbMTAwMV07CglpbnQgc3VtOwoKCWNpbiA+PiBuOwoJZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIGNpbiA+PiBhcnJbaV07CgoJc29ydChhcnIsIGFyciArIG4pOwoJc3VtID0gcmVzdWx0WzBdID0gYXJyWzBdOwoJZm9yIChpbnQgaSA9IDE7IGkgPCBuOyBpKyspCgl7CgkJcmVzdWx0W2ldID0gcmVzdWx0W2kgLSAxXSArIGFycltpXTsKCQlzdW0gKz0gcmVzdWx0W2ldOwoJfQoJY291dCA8PCBzdW07CglyZXR1cm4gMDsKfQ==