fork download
  1. -- yukicoder My Practice
  2. -- author: Leonardone @ NEETSDKASU
  3.  
  4. n = io.read()
  5.  
  6. gi = io.read():gmatch('%d+')
  7.  
  8. mx = 0
  9. ans = 0
  10.  
  11. for i = 1, n do
  12. v = tonumber(gi())
  13. if v > mx then
  14. mx = v
  15. elseif v > ans then
  16. ans = v
  17. end
  18. end
  19.  
  20. print(ans)
Success #stdin #stdout 0s 2792KB
stdin
5
3 1 4 2 5
stdout
2