提交时间:2024-03-02 15:17:29
运行 ID: 134260
#include <bits/stdc++.h> using namespace std; const int N = 1e5; //struct node //{ // int p , q; //}a[N]; //bool cmp(node x , node y) //{ // if(x.p != y.p) // return x.p < y.p; // return x.q < y.q; //} int a[N]; int main() { int n; cin >> n; for(int i =1 ;i <= n;i++) cin >> a[i]; sort(a + 1 , a + n + 1); int sum = a[1]; for(int i = 2;i <= n;i++) sum += a[i] + a[i - 1]; cout << sum; return 0; }