Derivative of a complex function wrt x_i

Given a function
[tex]
\sum_{j=0}^m(b_{ij}-euclid(x_i, x_j))^2,
[/tex]
where euclid(x_i, x_j) denotes the Euclidean distance (1D or 2D) between x_i and x_j.
I'm supposed to find the derivative with respect to x_i.
The sum sign and the dimensionality are the problem for me.
Any help on how to solve this is appreciated.