fork download
  1. #!/usr/bin/perl
  2. # yukicoder My Practice
  3. # author: Leonardone @ NEETSDKASU
  4.  
  5. my $n = $*IN.get;
  6. my @a = $*IN.get.words;
  7. my $mx = 0;
  8. my $ans = 0;
  9.  
  10. for @a {
  11. my $v = $_.Int;
  12. if $v > $mx {
  13. $mx = $v;
  14. } elsif $ans < $v && $v < $mx {
  15. $ans = $v;
  16. }
  17. }
  18.  
  19. say $ans;
Success #stdin #stdout 1.66s 188736KB
stdin
5
3 1 4 2 5
stdout
2