#define _USE_MATH_DEFINES #include using namespace std; //template #define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12; templateinline bool chmax(T& a,T b){if(ainline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;} //end int n,k; vector a; ll f(vector b,vector c){ int idx=0; ll res=0; int mi=inf,cnt=1; map vs,ss; rep(i,0,b.size()){ if(b[i]==mi)cnt++; else if(b[i]1)continue; while(idxmi){ vs[v]++; ss[v]+=idx+1; } else break; idx++; } int key=k-b[i]; if(vs.count(key)){ res+=vs[key]*(i+1)+ss[key]; } } return res; } ll rec(int lb,int rb){ if(rb-lb==1)return a[lb]*2==k; int m=(lb+rb)/2; ll res=rec(lb,m)+rec(m,rb); vector x(a.begin()+lb,a.begin()+m),y(a.begin()+m,a.begin()+rb); reverse(ALL(x)); res+=f(x,y)+f(y,x); return res; } int main(){ cin>>n>>k; a.resize(n); rep(i,0,n)cin>>a[i]; cout<