fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int T,n,a,b;
  5. int A[1005];
  6. int main() {
  7. ios_base::sync_with_stdio(false);
  8. cin.tie(NULL);
  9. cin >> T;
  10. while(T--)
  11. {
  12. a = 0;
  13. b = 0;
  14. cin >> n;
  15. for(int i = 1; i <= n; i++)
  16. {
  17. cin >> A[i];
  18. if(i <= n/2) a += A[i];
  19. else b += A[i];
  20. }
  21. cout << a*b << endl;
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0s 5272KB
stdin
3
4
1 2 3 4
3
4 5 6
1
2
stdout
21
44
0