#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  char c;
  int f = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') f = -1;
  x = (c & 15);
  while (isdigit(c = getchar())) x = (x << 1) + (x << 3) + (c & 15);
  x *= f;
}
const double pi = acos(-1);
int n, m, i, j, a[200005];
double ansx, ansy, ways;
int main() {
  read(n);
  read(m);
  for ((i) = 1; (i) <= (n); (i)++) {
    read(a[i]);
  }
  for ((i) = 1; (i) <= (n); (i)++)
    for ((j) = (i + 1); (j) <= (n); (j)++) {
      ansx += cos(pi * (a[i] + a[j]) / m) * (n - (j - i + 1));
      ansy += sin(pi * (a[i] + a[j]) / m) * (n - (j - i + 1));
      ansx += cos(pi * (a[i] + a[j] + m) / m) * ((j - i - 1));
      ansy += sin(pi * (a[i] + a[j] + m) / m) * ((j - i - 1));
    }
  ways = 1.0 * n * (n - 1) * (n - 2) / 6;
  printf("%.10lf %.10lf\n", ansx / ways, ansy / ways);
  return 0;
}
