#include <bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); }
template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

namespace graph {

using Node = ll;
using Weight = ll;
using Edge = std::pair<Node, Weight>;

template <bool Directed>
struct Graph : public vvec<Edge> {
    using vvec<Edge>::vvec;

    void add_edge(Node f, Node t, Weight w = 1) {
        (*this)[f].emplace_back(t, w);
        if (!Directed) (*this)[t].emplace_back(f, w);
    }

    Graph<Directed> build_inv() const {
        Graph<Directed> ret(this->size());
        for (Node i = 0; i < this->size(); i++) {
            for (const Edge &e : (*this)[i]) {
                Node j;
                Weight w;
                std::tie(j, w) = e;
                if (!Directed && j < i) continue;
                ret.add_edge(j, i, w);
            }
        }

        return ret;
    }
};

}

vec<bool> get_loop(const graph::Graph<true> &g, ll start) {
    vec<bool> ret(g.size());
    vec<bool> used(g.size());
    std::stack<ll> stk;
    stk.push(start);
    while (true) {
        ll cur = stk.top();
        if (used[cur]) {
            stk.pop();
            while (true) {
                ll n = stk.top();
                stk.pop();
                ret[n] = true;
                if (n == cur) break;
            }
            break;
        }
        used[cur] = true;
        stk.push(g[cur][0].first);
    }

    return ret;
}

bool solve() {
    ll n;
    std::cin >> n;
    graph::Graph<true> g(n);
    for (ll i = 0; i < n; i++) {
        ll p;
        std::cin >> p;
        g.add_edge(p - 1, i);
    }
    auto ig = g.build_inv();

    std::queue<ll> que;
    vec<bool> is_leaf(n);
    for (ll i = 0; i < n; i++) if (g[i].size() == 0) {
        que.push(i);
        is_leaf[i] = true;
    }

    if (que.empty()) return n % 2 == 0;

    auto loop = get_loop(ig, que.front());
    vec<ll> ans(n, -1);

    auto get_ch_num = [&](ll i) {
        std::set<ll> ch;
        for (auto &&e : g[i]) {
            ll c = e.first;
            ch.insert(ans[c]);
        }
        return ch;
    };

    auto calc_a = [&](ll i, ll ng = -1) {
        auto ch = get_ch_num(i);
        ch.insert(ng);
        ll ret = 0;
        for (;; ret++) if (ch.find(ret) == ch.end()) return ret;
    };

    while (que.size()) {
        ll cur = que.front();
        que.pop();
        ans[cur] = calc_a(cur);
        for (auto &&e : ig[cur]) {
            ll nxt = e.first;
            if (loop[nxt]) continue;
            que.push(nxt);
        }
    }

    auto check = [&](const vec<ll> &av) {
        for (ll i = 0; i < n; i++) {
            ll j = ig[i][0].first;
            if (av[i] == av[j]) return false;
        }
        for (ll i = 0; i < n; i++) {
            std::set<ll> st;
            for (auto &&e : g[i]) {
                ll nxt = e.first;
                if (av[nxt] < av[i]) st.insert(av[nxt]);
            }
            if (st.size() < av[i]) return false;
        }
        return true;
    };

    if (check(ans)) return true;

    auto nxt_n = [&](ll i) {
        return ig[i][0].first;
    };

    auto modify = [&](vec<ll> av, ll start) {
        ll cur = start;
        ll nxt = nxt_n(cur);
        while (start != nxt) {
            av[nxt] = calc_a(nxt, av[cur]);
            cur = nxt;
            nxt = nxt_n(nxt);
        }
        return check(av);
    };

    ll start = [&] {
        ll i;
        for (i = 0; i < n; i++) if (loop[i]) break;
        return i;
    }();
    auto st = get_ch_num(start);
    for (ll i = 0, cnt = 0; cnt < 2; i++) {
        if (st.find(i) != st.end()) continue;
        ans[start] = i;
        if (modify(ans, start)) return true;
        cnt++;
    }

    return false;
}

int main() {
    if (!solve()) std::cout << "IM";
    std::cout << "POSSIBLE\n";
    return 0;
}


Measured memory_bytes: 24848