#!/usr/bin/perl # yukicoder My Practice # author: Leonardone @ NEETSDKASU my $n = $*IN.get; my @a = $*IN.get.words.map({ .Int }); my $mx = 0; my $ans = 0; for @a { $mx = max($mx, $_); if $ans < $_ && $_ < $mx { $ans = $_; } } say $ans;