my code# include # include <肆粗stdlib.h>int cmp(const void *a, const void *b){ return *(__int64 *)a - *(__int64 *)b;}int main(){ __int64 i, n; __int64 data[10001]; __int64 sum, total, tmp; scanf("兆老%I64d"族雹升,&n); sum = total = tmp = 0; for(i = 0; i < n; i++) { scanf("%I64d",&data[i]); sum += data[i]; } qsort(data,n,sizeof(data[0]),cmp); for(i = 0; i < n; i++) { tmp += data[i]; total += sum-tmp-(n-i-1)*data[i]+i*data[i]-(tmp-data[i]); } printf("%I64d\n",total); return 1;}