AlgoUniversity
  • Go Back
Discussion
Second Smallest :

Author

Akshay Sharma

Difficulty Level : Medium

Submissions : 188

Asked In : Walmart

Marks :100

: 5 | : 0

You are given a list P which contains N numbers.

The element in P are permutations of numbers from 1 to N.

Your task in to calculate the number of elements (Pi)(1≤i≤N) that satisfy the following condition such that Pi is second smallest element among the three number that is (pi−1,PiandPi+1)

Input

The first line of input contains an integer N (3≤N≤50)

Next, the N line contains N integers (Pi)

Output

For each test case print the number of elements that is the second smallest among the three

Examples

Input
7
6 3 2 5 7 4 1
Output
3
Input
5
1 3 4 5 2
Output
2

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.