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
 
 #include<cstdio>
#include<algorithm>
using namespace std;
int a[];
int main()
{
__int64 n,j;
while(scanf("%I64d",&n)&&n)
{
for(__int64 i=;i<n;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+n);
j=a[n-]*(-n);
for(__int64 i=;i < n; i++)
j=j+a[n--i];
printf("%I64d\n",j);
}
}
 

最新文章

  1. 信息安全-5:RSA算法详解(已编程实现)[原创]
  2. Activity系列讲解---三大基本状态与七大生命周期函数
  3. MySQL级联删除的问题
  4. android技巧(一):如何方便知晓当前Activity?如何管理应用中的Activity?如何最佳的启动一个Activity?
  5. centOS6.5安装SUN-jdk7
  6. Create,Insert
  7. Regsvr32注册ActiveX控件
  8. 通过WebBrowser获取网页验证码
  9. [iOS基础控件 - 6.10.1] PickerView 餐点搭配Demo
  10. 用Python复习离散数学(一)
  11. 【原生js】js动态添加dom,如何绑定事件
  12. Linux下安装Java(JDK8)
  13. 多线程之:MESI-CPU缓存一致性协议
  14. Python3获取拉勾网招聘信息
  15. Python基础之re模块(正则表达式)
  16. HTML(三)
  17. 初学者须知 常见的HTML5开发工具有哪些
  18. 解决ubuntu 16.04+ Qt 5.7.1无法输入中文的问题
  19. VIM简单配置(windows)
  20. linq group by / distinct

热门文章

  1. python安装教学
  2. Fastjson详解
  3. .NET CORE技术路线图
  4. 上帝造题的七分钟2/花神游历各国/GSS4 线段树维护区间开方 By cellur925
  5. HDU 5558 后缀数组
  6. _bzoj1192 [HNOI2006]鬼谷子的钱袋【水题】
  7. LoadRunner12学习之路(6-8)
  8. Stamps ans Envelope Sive UVA - 242
  9. ACboy needs your help HDU - 1712
  10. 贪心 Codeforces Round #109 (Div. 2) B. Combination