#include <bits/stdc++.h>
using namespace std;
long long n, d[200001], l, la = 0, p1[200001], p2[200001], s;
bool f = 1;
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  if (false) cout << "ok";
  for (int i = 0; i <= n; i++) {
    cin >> d[i];
    s += d[i];
  }
  if (false) cout << "ok";
  for (int k = 1; k <= n; k++) {
    if ((d[k] > 1) && (d[k - 1] > 1)) {
      l = 1;
      p1[0] = 0;
      for (int i = 1; i <= n; i++) {
        p1[i] = i;
        for (int j = 1; j < d[i]; j++) {
          p1[n + l] = i;
          l++;
        }
      }
      p2[0] = 0;
      l = 1;
      for (int i = 1; i < k; i++) {
        p2[i] = i;
        for (int j = 1; j < d[i]; j++) {
          p2[n + l] = i;
          l++;
        }
      }
      p2[k] = k;
      p2[n + l] = n + l;
      l++;
      for (int j = 2; j < d[k]; j++) {
        p2[n + l] = k;
        l++;
      }
      for (int i = k + 1; i <= n; i++) {
        p2[i] = i;
        for (int j = 1; j < d[i]; j++) {
          p2[n + l] = i;
          l++;
        }
      }
      cout << "ambiguous" << endl;
      for (int i = 0; i < s; i++) {
        cout << p1[i] << ' ';
      }
      cout << endl;
      if (false) cout << "ok";
      for (int i = 0; i < s; i++) {
        cout << p2[i] << ' ';
      }
      if (false) cout << "ok";
      return 0;
    }
  }
  if (false) cout << "ok";
  cout << "perfect";
  return 0;
}
