int m;
cin >> m;
int* a = new int[m];
for (int j = 0; j < m; j++)
{
cin >> a[j];
}
int max1 = a[0];
int max2;
for (int j = 1; j < m; j++)
{
if (j == 1)
{
if (a[j] >= max1)
{
max2 = max1;
max1 = a[j];
}
else
{
max2 = a[j];
}
}
else
{
if (a[j] >= max1)
{
max2 = max1;
max1 = a[j];
}
else if (a[j]<max1 && a[j]>max2)
{
max2 = a[j];
}
}
}