fork download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n;
  7. double a, S=0;
  8. cin >> n;
  9. for(int i=1; i<=n; i++)
  10. {
  11. cin >> a;
  12. S+=fabs(a);
  13. }
  14. cout << S;
  15. return 0;
  16. }
Success #stdin #stdout 0s 3476KB
stdin
3
-6.73 2.01 5.99
stdout
14.73