This will be a simple problem on paper, but the brute force method is not really suitable for a computer, so I'm after a tricky algorithm that works in practice too: if $n$ positive half-integers $p_i$ are given, one can form $2^n$ linear combinations with coefficients $\pm 1$:

$$P = e_1 p_1 + \ldots + e_n p_n$$

Where $e_i = \pm 1$. With given $p_i$ one obtains $2^n$ values for $P$. Let's call $\mu(P)$ the multiplicity of $P$, the number of linear combinations that gives $P$. My goal is to know this $\mu(P)$. On a computer I could just loop over $2^n$ items given by n-length strings of +1 and -1's and record each $P$, but if $n$ is large ($n>64$) this becomes problematic if 64 bit integers are used (unsigned long long int in C). And also it becomes time consumong if $n$ is larger than 64 and some arbitrary precision library is used.

Is there a tricky way to obtain $\mu(P)$ that does not require a loop over $2^n$ elements?