Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Solution {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt(),tmp;
- int min1 = Integer.MIN_VALUE,min2 = Integer.MIN_VALUE;
- for(int i=0;i<n;i++){
- tmp = sc.nextInt();
- if(tmp>min1){
- min2 = min1;
- min1 = tmp;
- }else if(tmp>min2&&tmp!=min1){
- min2 = tmp;
- }
- }
- System.out.println(min2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment