Guest User

Untitled

a guest
Dec 26th, 2020
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. const n = parseInt(readline()), inputs = readline().split(' ');
  2. if(n == 0) return console.log(0);
  3. var diff = 0 - Math.abs(inputs[0]), res = inputs[0];
  4. for(let el of inputs) {
  5. if(0 - Math.abs(el) >= diff) {
  6. diff = 0 - Math.abs(el);
  7. res = el;
  8. for(let i = 0; i < n; i++) {
  9. if(parseInt(inputs[i]) == Math.abs(el)) res = Math.abs(el);
  10. }
  11. }
  12. }
  13.  
  14. console.log(res);
Advertisement
Add Comment
Please, Sign In to add comment