Advertisement
Guest User

Untitled

a guest
Dec 26th, 2020
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 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. if(inputs.includes(Math.abs(el))) res = Math.abs(el);
  9. }
  10. }
  11.  
  12. console.log(res);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement