#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long INF = 1ll << 60;
const double pi = acos(-1);
const double eps = 1e-8;
const long long mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};
int n, m;
vector<int> a;
int main() {
  cin >> n >> m;
  a = vector<int>(n);
  for (auto &i : a) cin >> i;
  double X = 0, Y = 0;
  for (int i = 0; i < n; i++) {
    int t = n - 2;
    for (int j = (i + 1) % n; t; j = (j + 1) % n) {
      double arg = pi * (a[i] + a[j] + (j < i ? m : 0)) / m;
      X += cos(arg) * t;
      Y += sin(arg) * t;
      t--;
    }
  }
  X /= (long long)n * (n - 1) * (n - 2) / 6;
  Y /= (long long)n * (n - 1) * (n - 2) / 6;
  cout << fixed << setprecision(11) << X << ' ' << Y << endl;
}
