for (i = 0; i < x; i++){
  while (a[i] > max){
   max = a[i];
   maxindex = i;
  }
 }
 for (i = 0; i < x; i++){
  while (a[i] > max2&& i != maxindex){
   max2 = a[i];
   secindex = i;
  }
 }
 for (i = 0; i < x;i++)
 while (a[i]>answer && i != maxindex && i != secindex){
  answer = a[i];
 }