Mathemmatical notation for the summation of the sets based on some other sets values. Here are the example set values.:  
X = [x1,x2,x3,x4,x5]
P = [x1,x1,x2,x3,x4,x1,x2,x5,x3,x2]

Here x1,x2,x3,x4,x5 are some numeric values.   
What I am trying to do is:  
Adding the respective values and creating a set according to the values in X
C = [3,3,2,1,1]

where,
C1, i.e. 3, is the sum of all the values of P which are equal to X[1]
C2, i.e. 2, is the sum of all the values of P which are equal to X[2]
C3, i.e. 1, is the sum of all the values of P which are equal to X[3]
C4, i.e. 1, is the sum of all the values of P which are equal to X[4]
C5, i.e. 3, is the sum of all the values of P which are equal to X[5]

I thought of something like the following, but it seems like it has flaws:
$$\sum_{k=1}^n P(x_k \in X) + C(x)$$
Please suggest me what could be the best possible output notation for the condition I have mentioned in my description.

Mathematically, $P$ is not a set since it can contain the same element several times. Instead it can be described as a function $P : \{ 1, \ldots, N_P \} \to X.$ Then $C$ is a function, $C : \{ 1, \ldots, N_X \} \to \{ 1, \ldots, N_P \}.$ We also have an enumeration $X_n$ of the elements in $X.$
Now $C_n$ should give the number of times that $x_n$ is "contained" in $P,$ i.e. the number of values in the domain of $P$ that map to $x_n$, we can write 
$$C_n = |P^{-1}(\{ X_n \})|.$$
Here $|S|$ denotes the number of elements in the set $S.$
