Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdio>
- #include<algorithm>
- using namespace std;
- int main()
- {
- long long int sum,a,b,c,d,e,f,g,h,i,j,k,l,array[5000],ans;
- while(a!=0)
- {
- cin>>a;
- for(i=0;i<a;i++)
- {
- cin>>array[i];
- }
- j=0;ans=0;
- while(j<a)
- {
- sort(array,array+a);
- array[j+1]=array[j]+array[j+1];
- array[j]=0;
- if(j!=a-1)ans+=array[j+1];
- j++;
- }
- if(a!=0)cout<<ans<<"\n";//array[a];
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment