import std.conv, std.stdio;
import std.algorithm, std.range, std.string;
import std.experimental.logger;

size_t p;
Polynomial[] left, right;

void main()
{
    p = readln.chomp.to!size_t;
    auto buf = readln.chomp.split.to!(int[]);
    auto cleft = constant(1), cright = constant(1);
    foreach (i; 0..p)
    {
        left ~= cleft;
        cleft = cleft * (x-constant(i));
    }
    right.length = p;
    foreach_reverse (i; 0..p)
    {
        right[i] = cright;
        cright = cright * (x-constant(i));
    }
    auto answer = constant(0);
    foreach (i, b; buf)
    {
        if (b)
            answer = answer - left[i].prod(right[i]);
    }
    "%(%d %)".writefln(answer.coeffs);
}
struct Polynomial
{
    size_t[] coeffs;
    auto opBinary(string op)(in Polynomial rhs) const
        if (op == "-")
    {
        return Polynomial(this.coeffs.zip(rhs.coeffs).map!(_ => (_[0]+p-_[1])%p).array);
    }
    auto opBinary(string op)(in Polynomial rhs) const
        if (op == "+")
    {
        return Polynomial(this.coeffs.zip(rhs.coeffs).map!(_ => (_[0]+  _[1])%p).array);
    }

    // ASSUME DEG(RHS) <= 1
    auto opBinary(string op)(in Polynomial rhs) const
        if (op == "*")
    {
        auto coeffs = new size_t[p];
        foreach (i, c; this.coeffs)
            foreach (j, d; rhs.coeffs[0..2])
            {
                if (p <= i+j)
                    continue;
                auto prod = c*d%p;
                coeffs[i+j] = (coeffs[i+j]+prod)%p;
            }
        return Polynomial(coeffs);
    }
}
Polynomial prod(in Polynomial lhs, in Polynomial rhs)
{
    auto coeffs = new size_t[p];
    foreach (i, c; lhs.coeffs)
        foreach (j, d; rhs.coeffs)
        {
            if (p <= i+j)
                continue;
            auto prod = c*d%p;
            coeffs[i+j] = (coeffs[i+j]+prod)%p;
        }
    return Polynomial(coeffs);
}
auto x()
{
    return Polynomial(only(0, 1).chain(size_t(0).repeat(p-2)).array);
}
auto constant(size_t j)
{
    return Polynomial(j.only.chain(0.repeat(p-1)).array);
}
