#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
#define debug printf("%s %d\n", __FUNCTION__, __LINE__)
const int inf = 2147483647;

const int maxn = 200000 + 10;
int n, tail;
int mark[maxn];
bool ring[maxn];
int status[maxn];
int anc[maxn];
int list[maxn];
vector<int> e[maxn];

void findRing(int u) {
    status[u] = -1;
    for (int i = 0; i < e[u].size(); i++) {
        int v = e[u][i];
        if (status[v] == -1) {
            int cur = u;
            while (true) {
                list[tail++] = cur;
                ring[cur] = true;
                if (cur == v) break;
                cur = anc[cur];
            }
            return ;
        } 
        else {
            anc[v] = u;
            findRing(v);
        }
    }
    status[u] = 1;
}

int sg[2][maxn];
bool used[maxn];
void getsg(int u) {
    for (int i = 0; i < e[u].size(); i++) {
        int v = e[u][i];
        if (!ring[v]) getsg(v);
    }
    for (int i = 0; i < e[u].size(); i++) {
        int v = e[u][i];
        if (!ring[v]) used[ sg[0][v] ] = true;
    }
    for (int i = 0; ; i++) {
        if (!used[i]) {
            if (sg[0][u] == -1) sg[0][u] = i;
            else {
                sg[1][u] = i;
                break;
            }
        }
    }
    for (int i = 0; i < e[u].size(); i++) {
        int v = e[u][i];
        if (!ring[v]) used[ sg[0][v] ] = false;
    }
}

int prev(int u) {
    return list[(u + tail - 1) % tail];
}

int next(int u) {
    return list[(u + 1) % tail];
}

int cur(int u) {
    return list[u];
}

bool vis[maxn][2];
int dep = 0;
bool work(int u, int inx, int st) {
    dep++;
    //for (int i = 1; i < dep; i++) cout << "    ";
    //cout << cur(u) << ' ' << inx << ' ' << st << endl;

    u %= tail;

    if (vis[u][inx]) {
        if (u == 0 && inx == st) return true;
        return false;
    }
    if (u == 0 && dep != 1) return false;

    vis[u][inx] = true;
    if (inx == 0) {
        if (sg[0][next(u)] != sg[inx][cur(u)]) {
            if (work(u + 1, 0, st)) return true;    
        }
        if (sg[1][next(u)] != sg[inx][cur(u)]) {
            if (work(u + 1, 1, st)) return true;    
        }
    }
    else {
        if (sg[0][next(u)] == sg[0][cur(u)]) {
            if (work(u + 1, 0, st)) return true;
        }
        if (sg[1][next(u)] == sg[0][cur(u)]) {
            if (work(u + 1, 1, st)) return true;
        }
    }
    dep--;
    return false;
}

int main(int argc, char **argv) {
    scanf("%d", &n);
    for (int i = 1, x; i <= n; i++) {
        scanf("%d", &x); 
        e[x].push_back(i);
    }
    for (int i = 1; i <= n; i++) mark[i] = -1;
    for (int i = 1; i <= n; i++) anc[i] = -1;
    for (int i = 1; i <= n; i++) sg[0][i] = sg[1][i] = -1;
    for (int i = 1; i <= n; i++) 
        if (status[i] == 0) findRing(i);
    for (int i = 0; i < tail; i++) getsg(list[i]);
    reverse(list, list + tail);

    if (tail == 0) {
        printf("POSSIBLE\n");
        return 0;
    }

    //for (int i = 0; i < tail; i++) cout << sg[1][cur(i)] << endl;
    
    if (work(0, 0, 0)) {
        printf("POSSIBLE\n");
        return 0;
    }
    //cout << "H" << endl;

    for (int i = 0; i < tail; i++) 
        vis[i][0] = vis[i][1] = false;
    if (work(0, 1, 1)) {
        printf("POSSIBLE\n");
        return 0;
    }

    printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 23168