fork download
  1. /******************************************************************************
  2.  
  3.   Online C++ Compiler.
  4.   Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15. int n;
  16. cin >> n;
  17.  
  18. int a[n];
  19. long long sum=0;
  20. for(int i=0; i<n; i ++) {
  21. cin >> a[i];
  22. sum += a[i];
  23. }
  24.  
  25. if(sum % 2 == 0) cout << sum;
  26. else{
  27. int min=a[0];
  28. for(int i=0; i<n; i ++){
  29. if(a[i] < min && a[i]%2 != 0){
  30. min = a[i];
  31. }
  32. }
  33. sum -= min;
  34. cout << sum;
  35. }
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 5296KB
stdin
Standard input is empty
stdout
-28813135008