/*
Author: vpetrigo
Task:
     
  0.   
     ,  
,   ,  
   .

  
   , 
 0 (  0    ,      ).

  
   .

Sample Input 1:
4
4
2
3
0
Sample Output 1:
4

Sample Input 2:
2
1
0
Sample Output 2:
1

*/

#include <iostream>

using namespace std;

int main() {
    int n;
    int max = -1;
    int s_max = -1;

    while (cin >> n && n != 0) {
        if (max < n) {
            max = n;
        }
        
        if (n <= max && s_max < n) {
            s_max = n;
        }
    }

    cout << s_max;

    return 0;
}
/*
Author: vpetrigo
Task:
     
  0.   
     ,  
,   ,  
   .

  
   , 
 0 (  0    ,      ).

  
   .

Sample Input 1:
4
4
2
3
0
Sample Output 1:
4

Sample Input 2:
2
1
0
Sample Output 2:
1

*/

#include <iostream>

using namespace std;

int main() {
    int n;
    int max = -1;
    int s_max = -1;

    while (cin >> n && n != 0) {
        if (max <= n) {
            s_max = max;
            max = n;
        }
        else if (s_max < n) {
            s_max = n;
        }
    }

    cout << s_max;

    return 0;
}
Revert "Revert "Solution for week 3, task 9""
Revert "Revert "Solution for week 3, task 9""

This reverts commit a280465d0b09e0aa9f9ec3b403b1bf3785b7d75a.
