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.

This might be a job for the Kronecker delta function. If $x = y$, then $\delta_y^x = 1$, but if $x \neq y$, then $\delta_y^x = 0$.
Then, if $\mathcal L_P$ is how many elements $P$ has and $\mathcal L_X$ is how many elements $X$ has, then, given $0 < n \leq \mathcal L_X$, we have $$C_n = \sum_{k = 1}^{\mathcal L_P} \delta_{X_n}^{P_k}.$$ Note bene that $n$ is a constant for the scope of the summation, but $k$ iterates and is a subscript for $P$, not $X$.
Others will have better ideas, but my idea is probably the best you can hope for on a Saturday afternoon.
