Find the second largest element & print "-1", if no such element exists

Find the second largest element & print "-1", if no such element exists


#include <stdio.h>
#include <limits.h>
int main(void) {
 int x,n,i,first=INT_MIN+1,second=INT_MIN;
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
  scanf("%d",&x);
  if(first<x)
  {
   second=first;
   first=x;
  }
  else if(x>second && x!=first)
  second=x;
 }
    if(second!=INT_MIN+1)
    printf("%d",second);
    else
        printf("-1");
 return 0;
}