Description
Giving N integers, V1, V2,,,,Vn, you should find the biggest value of F.
Input
Each test case contains a single integer N (1<=N<=100). The next line contains N integers, meaning the value of V1, V2....Vn.(1<= Vi <=10^8).The input is terminated by a set starting with N = 0. This set should not be processed.
Output
For each test case, output the biggest value of F you can find on a line.
Sample Input
2
1 2
0
Sample Output
4017
1 #include<cstdio> 2 #include<algorithm> 3 using namespace std; 4 int a[100000]; 5 int main() 6 { 7 __int64 n,j; 8 while(scanf("%I64d",&n)&&n) 9 { 10 for(__int64 i=0;i<n;i++) 11 { 12 scanf("%d",&a[i]); 13 } 14 sort(a,a+n); 15 j=a[n-1]*(2010-n); 16 for(__int64 i=1;i < n; i++) 17 j=j+a[n-1-i]; 18 printf("%I64d ",j); 19 } 20 }