#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cassert>

using std::vector;

typedef std::pair<int,int> pii;

const int INF = 1 << 30;

struct PosVal {
    int pos, val;

    PosVal(){}
    PosVal(int _pos, int _val) : pos(_pos), val(_val) {}

    bool operator < (const PosVal & other) const
    {
        return val < other.val;
    }

    bool operator > (const PosVal & other) const
    {
        return other < *this;
    }
};

struct MinMax {
    PosVal min, max;
    bool increase, decrease;
    
    MinMax()
    {
        min = PosVal(-1, INF);
        max = PosVal(-1, -INF);
        increase = decrease = true;
    }

    MinMax(PosVal v)
    {
        min = max = v;
        increase = decrease = true;
    }

    MinMax operator + (const MinMax & other) const
    {
        MinMax res;
        res.min = std::min(min, other.min);
        res.max = std::max(max, other.max);
        res.increase = increase && other.increase && max < other.min;
        res.decrease = decrease && other.decrease && min > other.max;
        return res;
    }
};

struct RangeTree {
    vector <MinMax> b;
    int kk;

    RangeTree (int n)
    {
        kk = 1;
        while (kk < n)
            kk *= 2;
        b.resize(2 * kk);
    }

    MinMax get(int l, int r)
    {
        l += kk;
        r += kk;
        MinMax left;
        MinMax right;
        while (l <= r)
        {
            if (l % 2 == 1)
            {
                left = left + b[l];
                ++l;
            }
            if (r % 2 == 0)
            {
                right = b[r] + right;
                --r;
            }
            l /= 2;
            r /= 2;
        }
        return left + right;
    }

    void modify(int t, int v)
    {
        PosVal val(t, v);
        t += kk;
        b[t] = val;
        while (t > 1)
        {
             t /= 2;
             b[t] = b[2 * t] + b[2 * t + 1];
        }
    }
};

struct List {
    vector <PosVal> left;
    vector <PosVal> right;

    vector <PosVal> toVector() const
    {
        vector <PosVal> res = left;
        for (vector<PosVal>::const_reverse_iterator it = right.rbegin(); it != right.rend(); ++it)
            res.push_back(*it);
        return res;
    }

    bool canAdd(PosVal posVal)
    {
        return (left.empty() || left.back().val < posVal.val) && (right.empty() || right.back().val > posVal.val);
    }

    void addLeft(PosVal posVal)
    {
        assert(canAdd(posVal));
        left.push_back(posVal);
    }

    void addRight(PosVal posVal)
    {
        assert(canAdd(posVal));
        right.push_back(posVal);
    }
};

void impossible()
{
    printf("Impossible\n");
    exit(0);
}

void printAnswer(const vector <PosVal> & ans)
{
    for (vector<PosVal>::const_iterator it = ans.begin(); it != ans.end(); ++it)
        printf("%d ", it -> pos + 1);
    printf("\n");
    exit(0);
}

void solve(vector <int> & v, RangeTree & tree, int l, int r, MinMax all)
{
    List increase, decrease;
    while (l <= r)
    {
        PosVal allMax = all.max;
        int posMax = allMax.pos;

        MinMax left = tree.get(l, posMax - 1);
        MinMax right = tree.get(posMax + 1, r);

        bool L = left.increase && increase.canAdd(left.min) && increase.canAdd(left.max) && decrease.canAdd(allMax);
        bool R = right.decrease && decrease.canAdd(right.min) && decrease.canAdd(right.max) && increase.canAdd(allMax);

        if (L)
        {
            for (int i = l; i < posMax; ++i)
                increase.addLeft(PosVal(i, v[i]));
            decrease.addRight(allMax);

            l = posMax + 1;
            all = right;
            continue;
        }
        if (R)
        {
            for (int i = r; i > posMax; --i)
                decrease.addLeft(PosVal(i, v[i]));
            increase.addRight(allMax);

            r = posMax - 1;
            all = left;
            continue;
        }
        impossible();
     }
     printAnswer(increase.toVector());
}

int main()
{
    freopen("parade.in", "r", stdin);
    freopen("parade.out", "w", stdout);

    int n;
    scanf("%d", &n);
    vector <int> a(n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &a[i]);

    RangeTree tree(n);
    for (int i = 0; i < n; ++i)
        tree.modify(i, a[i]);

    if (n == 1)
        impossible();

    MinMax all = tree.get(0, n - 1);

    if (all.increase || all.decrease)
    {
        printf("1\n");
        return 0;
    }

    solve(a, tree, 0, n - 1, all);

    return 0;
}