#include <iostream>
#include <utility>
#include <tuple>
#include <string>
#include <cstdint>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
using i64 = int64_t;
i64 mod;
struct Fp {
    i64 x;
    Fp (i64 x = 0) : x(x % mod) {}
    i64 value() const {
        return x;
    }
    Fp operator-() const {
        return Fp(mod - x);
    }
    template<class T>
    Fp pow(T k) const {
        Fp res = Fp(1), b = *this;
        for (; k > 0; k >>= 1) {
            if (k & 1) res *= b;
            b *= b;
        }
        return res;
    }
    Fp inv() const {
        return pow(mod - 2);
    }
    Fp& operator+=(Fp rhs) {
        x += rhs.x;
        if (x >= mod) x -= mod;
        return *this;
    }
    Fp& operator-=(Fp rhs) {
        *this += -rhs;
        return *this;
    }
    Fp& operator*=(Fp rhs) {
        (x *= rhs.x) %= mod;
        return *this;
    }
    Fp& operator/=(Fp rhs) {
        *this *= rhs.inv();
        return *this;
    }
};
Fp operator+(Fp lhs, Fp rhs) {
    return lhs += rhs;
}
Fp operator-(Fp lhs, Fp rhs) {
    return lhs -= rhs;
}
Fp operator*(Fp lhs, Fp rhs) {
    return lhs *= rhs;
}
Fp operator/(Fp lhs, Fp rhs) {
    return lhs /= rhs;
}
bool operator==(Fp lhs, Fp rhs) {
    return lhs.x == rhs.x;
}
template<class T>
struct LagrangeInterpolation {
    vector<T> xs, ys, ws;
    template<class A, class B>
    LagrangeInterpolation(const A& xs, const B& ys) : xs(xs), ys(ys) {
        ws.resize(size());
        for (int i = 0; i < size(); ++i) {
            ws[i] = T(1);
            for (int j = 0; j < size(); ++j) {
                if (i != j) {
                    ws[i] *= xs[i] - xs[j];
                }
            }
        }
    }
    T operator()(T x) const {
        T p = T(1);
        for (int i = 0; i < size(); ++i) {
            if (x == xs[i]) {
                return ys[i];
            }
            p *= x - xs[i];
        }
        T l = T(0);
        for (int i = 0; i < size(); ++i) {
            l += ys[i] / (ws[i] * (x - xs[i]));
        }
        return p * l;
    }
    size_t size() const {
        return xs.size();
    }
    vector<T> expand() const {
        int n = size();
        vector<T> l(n + 1);
        l[n] = T(1);
        for (int i = 0; i < n; ++i) {
            for (int j = n - i; j <= n; ++j) {
                l[j - 1] -= xs[i] * l[j];
            }
        }
        vector<T> res(n);
        vector<T> q(n);
        q[n - 1] = T(1);
        // q[n-1]x^(n-1) + q[n-2]x^(n-2) + ...
        // = (l[n]x^n + l[n]x^(n-1) + ...) / (x + (-xs[i]))
        for (int i = 0; i < n; ++i) {
            for (int j = n - 1; j > 0; --j) {
                q[j - 1] = l[j] + xs[i] * q[j];
            }
            T k = ys[i] / ws[i];
            for (int j = 0; j <= n - 1; ++j) {
                res[j] += k * q[j];
            }
        }
        return res;
    }
};
int main() {
    i64 p;
    cin >> p;
    mod = p;
    vector<Fp> xs(p), ys(p);
    for (int i = 0; i < p; ++i) {
        xs[i] = i;
        cin >> ys[i].x;
    }
    LagrangeInterpolation<Fp> li(xs, ys);
    auto bs = li.expand();
    for (int i = 0; i < p; ++i) {
        cout << bs[i].value() << ' ';
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 512