题目链接:传送门
直接枚举最大值往左右扩就过了,,
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <algorithm>
#include <climits>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define
#define
using namespace std;
typedef long long ll;
int n, a[A], ans;
int main(int argc, char const *argv[]) {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 2; i < n; i++) {
set<int> s;
if (a[i] < a[i + 1] or a[i] < a[i - 1]) continue;
for (int j = i - 1; j >= 1 and a[j] < a[i]; j--) s.insert(a[j]);
for (int j = i + 1; j <= n and a[j] < a[i]; j++) if (s.count(a[i] - a[j])) ans++;
}
cout << ans << endl;
}