#include int main(){ int n,a,b,t; scanf("%d%d",&n,&a); scanf("%d%d",&a,&b);b>a&&(a^=b^=a^=b); while(n-->2){scanf("%d",&t);a=t>a?t:a;b=t