#include <algorithm>
#include <iostream>
#include <queue>
#include <set>

using namespace std;
typedef pair<int,int> pii;

const int MAXN = 2e5+5;

int N;
int p[MAXN], d[MAXN], a[MAXN];
set<pii> ints[MAXN];

void remove(int i, int x) {
        if (x < ints[i].begin()->first) return;
        auto it = ints[i].upper_bound(pii(x,1));
        it--;
        if (it->first == x) {
                if (it->second == 0) {
                        ints[i].erase(it);
                        ints[i].insert(pii(x+1,0));
                } else {
                        ints[i].erase(it);
                        ints[i].insert(pii(x-1,1));
                }
        } else if (it->second == 0) {
                ints[i].insert(pii(x-1,1));
                ints[i].insert(pii(x+1,0));
        }
}

int mex(int i) {
        return ints[i].begin()->first;
}

int mex2(int i) {
        auto it = ints[i].begin();
        int x = it->first;
        it++;
        if (it == ints[i].end() || it->first != x) {
                return x+1;
        } else {
                it++;
                return it->first;
        }
}

int main() {
        cin >> N;
        for (int i=0; i<N; i++) {
                cin >> p[i];
                p[i]--;
                d[p[i]]++;
                ints[i].insert(pii(0,0));
        }

        queue<int> tq;
        for (int i=0; i<N; i++)
                if (d[i] == 0)
                        tq.push(i);

        while (tq.size() > 0) {
                int cur = tq.front();
                tq.pop();
                a[cur] = mex(cur);
                remove(p[cur],a[cur]);
                d[p[cur]]--;
                if (d[p[cur]] == 0)
                        tq.push(p[cur]);
                //cout << "Assigned " << a[cur] << " to " << cur << "\n";
        }

        /*cout << "Trees done!\nRemaining:\n";
        for (int i=0; i<N; i++) {
                if (d[i] == 1) {
                        cout << i << " " << mex(i) << " " << mex2(i) << ": ";
                        for (auto p : ints[i])
                                cout << p.first << " ";
                        cout << "\n";
                }
        }*/

        for (int i=0; i<N; i++) {
                if (d[i] == 1) {
                        //Try both completions
                        int cur=i,cura=mex(i);
                        while (p[cur] != i) {
                                cur = p[cur];
                                if (mex(cur) == cura)
                                        cura = mex2(cur);
                                else
                                        cura = mex(cur);
                        }

                        if (cura != mex(i)) {
                                cout << "POSSIBLE\n";
                                return 0;
                        }

                        cur=i,cura=mex2(i);
                        while (p[cur] != i) {
                                cur = p[cur];
                                if (mex(cur) == cura)
                                        cura = mex2(cur);
                                else
                                        cura = mex(cur);
                        }

                        if (cura == mex(i)) {
                                cout << "POSSIBLE\n";
                                return 0;
                        }

                        cout << "IMPOSSIBLE\n";
                        return 0;
                }
        }

        cout << "POSSIBLE\n";
}

Measured memory_bytes: 21248