private void Max_Click(object sender, EventArgs e)
{
  int max1, max2, max3;
  int j;
  listBox1.Items.Add(a[0].ToString());
  max1 = max2 = max3 = a[0];
  for (j = 1; j < count; j++)
  {
     listBox1.Items.Add(a[j].ToString());
     if (a[j] > max1)
     {
        max3 = max2;
        max2 = max1;
        max1 = a[j];
     }
     else if (a[j] > max2)
     {
        max3 = max2;
        max2 = a[j];
     }
  else if (a[j] > max3)
       max3 = a[j];
  }
  label2.Text = "Result is " + max3.ToString();
}

