Find how many pair elements sums up to N Based on a recent question in StackOverflow

Write a program/function that takes in one ARRAY/list and returns the number of pair-values which sums up to a given TOTAL.

Explaining

TOTAL=4, ARRAY=[1,3,7,1,-3] =&gt; RESULT=2


The result was 2 because 1 + 3 and 7 + -3 are valid pairs which sums up to TOTAL=4.


When one pair is formed, you should not count any of its values again
Also, you are not allowed to add any value that is not present in the ARRAY.


This is code-golf, shortest in bytes wins

All values will be between your language's int min-max.

Another cases

9, [1,2,3,5,4,6,7,-10] =&gt; 3          // [2,7]  [3,6]  [5,4]
0, [] =&gt; 0                           //
0, [1,-2,0,-1,2] =&gt; 2                // [1,-1]  [-2,2]
5, [5,5,5,0,-1,1,-5] =&gt; 1            // [5,0]
3, [7,-7,8,3,9,1,-1,5] =&gt; 0          //
2, [1,1] =&gt; 1                        // [1,1]
2, [1,1,1,1,1] =&gt; 2                  // [1,1]  [1,1]
4, [1,3,3,3] =&gt; 1                    // [1,3]
Pyth, 9 bytes

/sM{.cSE2


Test suite

Takes the number and array newline separated.

Explanation:

/sM{.cSE2
/sM{.cSE2Q    Implicit variable introduction.
              Implicit: Q = eval(input())
       E      Take the array as input.
      S       Sort the input.
    .c  2     Form all ordered pairs.
   {          Deduplicate.
 sM           Map each to its sum.
/        Q    Count the number of occurrences of Q in the resulting list.