Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const n = parseInt(readline()), inputs = readline().split(' ');
- if(n == 0) return console.log(0);
- var diff = 0 - Math.abs(inputs[0]), res = inputs[0];
- for(let el of inputs) {
- if(0 - Math.abs(el) >= diff) {
- diff = 0 - Math.abs(el);
- res = el;
- if(inputs.includes(Math.abs(el))) res = Math.abs(el);
- }
- }
- console.log(res);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement