Problem: We have a permutation p = {p_1,\ p_2,\ ...,\ p_n} of {1,\ 2,\ ...,\ n}.  Print the number of elements p_i (1 < i < n) that satisfy the following condition:    * p_i is the second smallest number among the three numbers p_{i - 1}, p_i, and p_{i + 1}.

Submission attempts (in order):
n = input()
a = list( input().split())
cnt = 0
for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
if len(a) = 3:
  if a[1] = 2:
    cnt = 1
    
print (cnt)    

n = input()
a = list( input().split())
cnt = 0
for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
if len(a) = 3 and a[1] = 2:
    cnt = 1
    
print (cnt)    

n = input()
a = list( input().split())
cnt = 0

if (len(a) = 3) and (a[1] = 2):
  cnt = 1

else:
  for i in range ( 1, len(a)-1):
    if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
      cnt += 1
    
print (cnt)    


n = input
a = list (input())

cnt = 0
if len(a)==3:
  if a[1] == 2:
    cnt = 1
  else :
    cnt = 0
    
else:
  for i in range (1, len(a)-1):
    if (a[i-1]<a[i]<a[i+1]) or (a[i-1]>a[i]>a[i+1]):
      cnt += 1
    
print(cnt)    

n = int( input())
a = list( int(input().split()))
cnt = 0

for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
print (cnt)    


n = input
a = list (input())

cnt = 1
for i in range (1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) and (a[i-1]>a[i]>a[i+1]):
    cnt += 1
    
if len(a)==3:
  if a[1] == 2:
    cnt = 1
  else :
    cnt = 0
    
print(cnt)    

n = input
a = list (input())

cnt = 0
for i in range (1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i-1]>a[i]>a[i+1]):
    cnt += 1
    
if len(a)==3:
  if a[1] == 2:
    cnt = 1
  else :
    cnt = 0
    
else:
  for i in range (1, len(a)-1):
    if (a[i-1]<a[i]<a[i+1]) and (a[i-1]>a[i]>a[i+1]):
      cnt += 1
    
print(cnt)    

n = input()
a = list( input().split())
cnt = 0
for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
if (len(a) = 3) and (a[1] = 2):
  cnt = 1
    
print (cnt)    

n = input
a = list (input())

cnt = 0
if len(a)==3:
  if a[1] == 2:
    cnt = 1
  else :
    cnt = 0
    
else:
  for i in range (1, len(a)-1):
    if (a[i-1]<a[i]<a[i+1]) and (a[i-1]>a[i]>a[i+1]):
      cnt += 1
    
print(cnt)    

n = input
a = list (input())

cnt = 0
for i in range (1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) and (a[i-1]>a[i]>a[i+1]):
    cnt += 1
    
if len(a)==3:
  if a[1] == 2:
    cnt = 1
  else :
    cnt = 0
    
else:
  for i in range (1, len(a)-1):
    if (a[i-1]<a[i]<a[i+1]) and (a[i-1]>a[i]>a[i+1]):
      cnt += 1
    
print(cnt)    

n = int( input())
a = list( map(int(input().split())))
cnt = 0

for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
print (cnt)    


n = int(input())
a = list (int(input()))

cnt = 0
for i in range (1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i-1]>a[i]>a[i+1]):
    cnt += 1
    
print(cnt)    


n = input
a = list (input())

cnt = 0
for i in range (1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) and (a[i-1]>a[i]>a[i+1]):
    cnt += 1
    
if len(a)==3:
  if a[1] == 2:
    cnt = 1
  else :
    cnt = 0
    
print(cnt)    

n = int( input())
a = list( map( int, input().split()))
cnt = 0

for i in range ( 1, len(a)-1):
  if (a[i-1]<a[i]<a[i+1]) or (a[i+1]<a[i]<a[i-1]):
    cnt += 1
    
print (cnt)    


Verdicts: Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Accepted