#include <bits/stdc++.h>
#define prev someone_else_0
#define last someone_else_1
#define next someone_else_2

using namespace std;

const long double eps = 1e-9;

const int MaxN = 2e5 + 15;

int n;

vector <int> v[MaxN];
set<pair<int, int> > s;

int color[MaxN];
int c[MaxN];
int cnt[MaxN];
int prev[MaxN];

void print(vector <int> v)
{
    cout << v.size() << '\n';
    for(int i = 0; i < v.size(); ++i)
        cout << v[i] << ' ';
    cout << '\n';
}

inline void make(int x)
{
    bool used[v[x].size() + 2];
    memset(used, 0, sizeof(used));
    for(int i = 0; i < v[x].size(); ++i)
    {
        int to = v[x][i];
        used[color[to]] = true;
    }

    s.erase(make_pair(cnt[prev[x]], prev[x]));
    --cnt[prev[x]];
    s.insert(make_pair(cnt[prev[x]], prev[x]));
    for(int i = 0; ; ++i)
        if(!used[i])
        {
            color[x] = i;
            return;
        }
}

bool good(int x)
{
    if(c[x] == c[prev[x]])
        return false;
    bool used[v[x].size() + 3];
    memset(used, 0, sizeof(used));
    for(int i = 0; i < v[x].size(); ++i)
    {
        int to = v[x][i];
        used[c[to]] = true;
    }
    for(int i = 0; ; ++i)
    if(!used[i])
    {
        if(c[x] != i)
            return false;
        break;
    }
    return true;
}



void tryOne(vector <int> order, int pos, int COLOR)
{
    for(int i = 1; i <= n; ++i)
        c[i] = color[i];

    c[order[pos]] = COLOR;
//    cout << order[pos] << ' ' << COLOR << '\n';

    for(int i = pos + 1; i < order.size(); ++i)
    {
        int x = order[i];
        //cout << "A " << x << '\n';
        bool used[v[x].size() + 3];
        memset(used, 0, sizeof(used));
        for(int i = 0; i < v[x].size(); ++i)
        {
            int to = v[x][i];
            used[c[to]] = true;
            //cout << "B " << to << ' ' << color[to] << '\n';
        }
        for(int i = 0; ; ++i)
        if(!used[i])
        {
            c[x] = i;
            break;
        }
    }
    for(int i = 0; i < pos; ++i)
    {
        int x = order[i];
        //cout << "A " << x << '\n';
        bool used[v[x].size() + 3];
        memset(used, 0, sizeof(used));
        for(int i = 0; i < v[x].size(); ++i)
        {
            int to = v[x][i];
            used[c[to]] = true;
        }
        for(int i = 0; ; ++i)
        if(!used[i])
        {
            c[x] = i;
            break;
        }
    }

    //for(int i = 1; i <= n; ++i)
        //cout << i << ' ' << c[i] << '\n';

    for(int i = 0; i < order.size(); ++i)
    {
        int x = order[i];
        if(good(x))
            continue;
        else
            return;
    }
    cout << "POSSIBLE\n";
    exit(0);
}

void go(int x)
{
    bool used[v[x].size() + 3];
    memset(used, 0, sizeof(used));
    int needColor = 0;
    int TO;
    for(int i = 0; i < v[x].size(); ++i)
    {
        int to = v[x][i];
        if(color[to] > -1)
            used[color[to]] = true;
        else
            TO = to;
    }
    int COLOR;
    for(int i = 0; ; ++i)
        if(!used[i])
        {
            COLOR = i;
            break;
        }
    vector <int> order;
    order.push_back(x);
    for(int X = prev[x]; X != x; X = prev[X])
        order.push_back(X);
    //print(order);
    tryOne(order, 0, COLOR);
    tryOne(order, order.size() - 1, COLOR);
}

int main()
{
//    freopen("input.txt", "r", stdin);
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for(int i = 1; i <= n; ++i)
    {
        int p;
        cin >> p;
        prev[i] = p;
        v[p].push_back(i);
        ++cnt[p];
        color[i] = -1;
    }
    for(int i = 1; i <= n; ++i)
        s.insert(make_pair(cnt[i], i));
    while(!s.empty() && (*s.begin()).first == 0)
    {
        pair<int, int> cur = (*s.begin());
        s.erase(s.begin());
        make(cur.second);
    }
    for(int i = 1; i <= n; ++i)
        if(color[i] == -1)
        {
            go(i);
            cout << "IMPOSSIBLE\n";
            return 0;
        }
    cout << "IMPOSSIBLE\n";
    return 0;
}
/**
4 4
2 5
3 3
1 4
2 2
0 3
1 1
*/


Measured memory_bytes: 23924