I am unable to solve

## this problem

under given constraints. Can anyone can provide hints/ideas/or solutions on how to solve this?

## Problem Statement:

In this problem you are given a sequence of N positive integers S1,S[2], … S[N].

In addition you are given an integer T, and your aim is to find the number of quadruples (i, j, k, l),

such that 1 <= i < j < k < l <= N, and S[i] + S[j] + S[k] + S[l] = T.

That is, the number of ways of picking four numbers from the sequence summing up to T.

## Contraints:

1 <= N <= 5000

1 <= T <= 1000000

1 <= S[i] <= 1000000000 , for all i.