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.

You can find all combinations(I hope you have knowledge of permutations and combinations) of the array having four elements.

If the sum of the array is T you can increment counter, which will give the answer after you have gone through all possible combinations.

A way to optimize this approach would be to sort the array before finding the combinations, by this we can stop making combinations for a particular case if the sum exceeds T.

Since, the constraints are not to big I think this program won’t give TLE.