简单枚举一下就 完事了
import java.util.*;
class Main{
public static void main(String[] args) {
Scanner in =new Scanner(System.in);
int n=in.nextInt();
int a[]=new int [n];
for(int i=0;i[HTML_REMOVED]a[i+1]&&a[i+2]>a[i+1])||(a[i]<a[i+1]&&a[i+2]<a[i+1])) {
ans++;
}
}
}
System.out.println(ans);
}
}