from cmath import rect, pi
def main():
    n, m = map(int, raw_input().split())
    a = [int(raw_input()) for _ in xrange(n)]
    a.sort()
    ans = 0j
    for i, x in enumerate(a):
        for j in xrange(i + 1, n):
            t = rect(1., pi * (x + a[j]) / m)
            ans += t * (n - j + i - 1) - t * (j - i - 1)
    ans /= n * (n - 1) / 2
    ans *= 3. / 2
    print "%.12f %.12f" % (ans.real, ans.imag)
main()
