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

size_t p;

void main()
{
    p = readln.chomp.to!size_t;
    auto buf = readln.chomp.split.to!(int[]);
    auto answer = x-x;
    foreach (i, b; buf)
        if (b)
            answer = answer - i.solve;
    "%(%d %)".writefln(answer.coeffs);
}
Polynomial solve(size_t i)
{
    auto ret = constant(1);
    foreach (j; 0..p)
        if (i != j)
            ret = ret * (x-constant(j));
    return ret;
}
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);
    }
    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)
            {
                auto prod = c*d%p;
                if (p <= i+j)
                    assert (!prod);
                else
                    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);
}
