fork download
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<cstdio>
  4. #include<map>
  5. #include<algorithm>
  6. #include<cstring>
  7. #include<cmath>
  8. #include<vector>
  9. #define f(i,a,n) for(int i=a;i<n;i++)
  10. #define ll long long
  11. #define si(a) scanf("%d",&a)
  12. #define sl(a) scanf("%lld",&a)
  13. #define ss(s) scanf("%s",s)
  14. using namespace std;
  15. int main()
  16. {
  17. int t;
  18. int n;
  19. si(t);
  20. while(t--)
  21. {
  22. si(n);
  23. int a[n];
  24. int pos=-1;
  25. ll sum=0;
  26. int min=10000000;
  27. f(i,0,n)
  28. {
  29. si(a[i]);
  30. if(min>a[i])
  31. {
  32. min=a[i];
  33. pos=i;
  34. }
  35. }
  36. f(i,0,n)
  37. {
  38. if(i!=pos)
  39. {
  40. sum+=a[i]*min;
  41. }
  42. }
  43. printf("%lld\n",sum);
  44. }
  45. // system("Pause");
  46. return 0;
  47. }
Success #stdin #stdout 0s 3344KB
stdin
1
3
1000000 1000000 1000000
stdout
-1454759936