#include <bits/stdc++.h>
using namespace std;
using LL = long long;
constexpr int N = 1e5 + 5;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> in(n + 1);
  for (int &e : in) cin >> e;
  assert(in[0] == 1);
  vector<int> prev_level{1};
  vector<int> pa(1), pb(1);
  int v = 1;
  for (int i = 1; i <= n; i++) {
    in[i]--;
    v++;
    vector<int> cur_level;
    pa.push_back(prev_level[0]);
    pb.push_back(prev_level[0]);
    cur_level.push_back(v);
    while (in[i]--) {
      ++v;
      pa.push_back(prev_level[0]);
      pb.push_back(prev_level.back());
      cur_level.push_back(v);
    }
    prev_level = cur_level;
  }
  if (pa == pb)
    cout << "perfect\n";
  else {
    cout << "ambiguous\n";
    for (int x : pa) cout << x << ' ';
    cout << "\n";
    for (int x : pb) cout << x << ' ';
    cout << "\n";
  }
}
