# 13591 - Second Highest Value >author: Utin ###### tags: `math` --- ## Brief See the code below ## Solution 0 ```c= #include<stdio.h> int arr[1000001]; int main() { int n, temp[2]; scanf("%d", &n); for(int i=0; i<n; i++) { scanf("%d", &arr[i]); } for(int i=0; i<n; i++) { if(i == 0) { temp[0] = arr[i]; temp[1] = arr[i]; printf("%d", 0); } else if(i == 1) { if(arr[i] > arr[i-1]) temp[1] = arr[i]; else temp[0] = arr[i]; printf("%d", temp[0]); } else { if(arr[i] > temp[1]) { temp[0] = temp[1]; temp[1] = arr[i]; } else if(arr[i]>temp[0] && arr[i]<temp[1]) { temp[0] = arr[i]; } printf("%d", temp[0]); } if(i != n-1) printf(" "); else printf("\n"); } } // By Utin ``` ## Reference