https://www.acmicpc.net/problem/11399
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int solution(int n, vector<int> p){
int answer =0;
sort(p.begin(), p.end());
int sum = 0;
for(int i=0;i<n;i++){
sum += p[i];
answer += sum;
}
return answer;
}
#include<stdio.h>
int main(){
int i,n,j,p[1001],temp,sum=0;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&p[i]);
}
for(int i=1; i<n;i++){
for(int j=0; j<n-i; j++){
if(p[j]>p[j+1]){
int temp = p[j];
p[j] = p[j+1];
p[j+1]=temp;
}
}
}
for(int i=0; i<n ;i++){
for(int j=0 ; j<=i ;j++){
sum+=p[j];
}
}
printf("%d",sum);
}