double dist(int n, double* p1, double* p2);