#include #include #include #include #include #include #include #include using namespace atcoder; using namespace std; #define reps(i, a, n) for (int i = (a); i < (int)(n); ++i) #define rep(i, n) reps(i, 0, n) #define repe(i,n) for(auto i : n) #define ALL(x) x.begin(),x.end() #define SIZE(x) ll(x.size()) #define INF32 2147483647 //2.147483647×10^{9}:32bit整数のinf #define INF64 9223372036854775807 //9.223372036854775807×10^{18}:64bit整数のinf #define MOD 1000000007 //問題による #define F first #define S second #define ll long long #define cYes cout << "Yes" << endl; #define cNo cout << "No" << endl; #define coutALL(x) for(auto i=x.begin();i!=--x.end();i++)cout<<*i<<" ";cout<<*--x.end()< #define vvi vector > #define vll vector #define vvll vector > using namespace std; using namespace atcoder; int main() { int n; cin >> n; vi a(n); rep(i,n) cin >> a[i]; map le; ll sm = 0; rep(i,n){ map ri; reps(j,i+1,n){ ri[a[j]]++; } reps(j,i+1,n){ ri[a[j]]--; auto ite = ri.find(a[i]+1); auto ite2 = le.find(a[j]-10); //cout4(a[i],a[j],ite->S,ite2->S); if(ite != ri.end() && ite2 != le.end()){ sm += ite->S * ite2->S; } } le[a[i]]++; } cout << sm << endl; }