#include #include #include using namespace std; using namespace atcoder; using mint = modint998244353; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 4000000000000000001 int main(){ int n; cin>>n; vector a(n); rep(i,n)cin>>a[i]; long long ans = 0; rep(i,n){ vector x(2005),y(2005); long long sum = 0; for(int j=i+1;j0)y[t]++; } for(int j=i+1;j0){ y[t]--; sum -= x[t]; } if(a[j]==a[i]+10)ans += sum; t = a[j] - a[i] - 10; if(t>0){ x[t]++; sum += y[t]; } } } cout<