#include<bits/stdc++.h>

using namespace std;

enum value_type{
     intp,
     floatp,
     vectorp,
     stringp,
     consp,
     tp,
     functionp,
     nilp
};

class lisp_cons;
class lisp_valiable;

class lisp_valiable{
public:
  void* value;
  value_type type;
  lisp_valiable(int x){
    type = intp;
    *(long long*)(value=(void*)new long long) = x;
  }
  lisp_valiable(long long x){
    type = intp;
    *(long long*)(value=(void*)new long long) = x;
  }
  lisp_valiable(float x){
    type = floatp;
    *(double*)(value=(void*)new double) = x;
  }
  lisp_valiable(double x){
    type = floatp;
    *(double*)(value=(void*)new double) = x;
  }
  lisp_valiable(vector<lisp_valiable> x){
    type = vectorp;
    *(vector<lisp_valiable>*)(value=(void*)new vector<lisp_valiable>) = x;
  }
  lisp_valiable(vector<lisp_valiable> *x){
    type = vectorp;
    value = (void*) x;
  }
  lisp_valiable(string x){
    type = stringp;
    *(string*)(value=(void*)new string) = x;
  }
  lisp_valiable(string *x){
    type = stringp;
    value = (void*) x;
  }
  lisp_valiable(lisp_cons *x){
    type = consp;
    value = (void*) x;
  }
  lisp_valiable(value_type type_){
    if(type_==nilp){
      type = nilp;
      return;
    }
    if(type_==tp){
      type = tp;
      return;
    }
    cout << "lisp_valiable(valu_type): BAD LISP INIT VARIABLE TYPE ERROR" << endl;
    exit(1);
  }
  lisp_valiable(function<lisp_valiable(lisp_valiable)> x){
    type = functionp;
    *(function<lisp_valiable(lisp_valiable)>*)(value=(void*)new function<lisp_valiable(lisp_valiable)>) = x;
  }
  lisp_valiable(bool x){
    if(x)type = tp;
    else type = nilp;
  }
  lisp_valiable(const lisp_valiable &x){
    if(x.type == intp){
      type = intp;
      *(long long*)(value=(void*)new long long) = *(long long*)x.value;
      return;
    }
    if(x.type == floatp){
      type = floatp;
      *(double*)(value=(void*)new double) = *(double*)x.value;
      return;
    }
    if(x.type == functionp){
      type = functionp;
      *(function<lisp_valiable(lisp_valiable)>*)(value=(void*)new function<lisp_valiable(lisp_valiable)>) = *(function<lisp_valiable(lisp_valiable)>*)x.value;
      return;
    }
    type = x.type;
    value = x.value;
    return;
  }
  lisp_valiable(){
    type = nilp;
  }

  ~lisp_valiable(){
    if(type==intp){
      delete (long long*)value;
      return;
    }
    if(type==floatp){
      delete (double*)value;
    }
    if(type==functionp){
      delete (function<lisp_valiable(lisp_valiable)>*)value;
    }
  }

  lisp_valiable operator=(lisp_valiable other){
    if(other.type == intp){
      type = intp;
      *(long long*)(value=(void*)new long long) = *(long long*)other.value;
      return other;
    }
    if(other.type == floatp){
      type = floatp;
      *(double*)(value=(void*)new double) = *(double*)other.value;
      return other;
    }
    if(other.type == functionp){
      type = functionp;
      *(function<lisp_valiable(lisp_valiable)>*)(value=(void*)new function<lisp_valiable(lisp_valiable)>) = *(function<lisp_valiable(lisp_valiable)>*)other.value;
      return other;
    }
    type = other.type;
    value = other.value;
    return other;
  }
};

lisp_valiable operator+(lisp_valiable x,lisp_valiable y){
  if(x.type == intp and y.type == intp){
    return lisp_valiable(*(long long*)x.value+*(long long*)y.value);
  }
  if(x.type == floatp and y.type == intp){
    return lisp_valiable(*(double*)x.value+*(long long*)y.value);
  }
  if(x.type == intp and y.type == floatp){
    return lisp_valiable(*(long long*)x.value+*(double*)y.value);
  }
  if(x.type == floatp and y.type == floatp){
    return lisp_valiable(*(double*)x.value+*(double*)y.value);
  }
  cout << "lisp_valiable operator+: BAD VARIABLE TYPE ERROR" << endl;
  exit(1);
}

lisp_valiable operator-(lisp_valiable x,lisp_valiable y){
  if(x.type == intp and y.type == intp){
    return lisp_valiable(*(long long*)x.value-*(long long*)y.value);
  }
  if(x.type == floatp and y.type == intp){
    return lisp_valiable(*(double*)x.value-*(long long*)y.value);
  }
  if(x.type == intp and y.type == floatp){
    return lisp_valiable(*(long long*)x.value-*(double*)y.value);
  }
  if(x.type == floatp and y.type == floatp){
    return lisp_valiable(*(double*)x.value-*(double*)y.value);
  }
  cout << "lisp_valiable operator-: BAD VARIABLE TYPE ERROR" << endl;
  exit(1);
}

lisp_valiable operator*(lisp_valiable x,lisp_valiable y){
  if(x.type == intp and y.type == intp){
    return lisp_valiable(*(long long*)x.value**(long long*)y.value);
  }
  if(x.type == floatp and y.type == intp){
    return lisp_valiable(*(double*)x.value**(long long*)y.value);
  }
  if(x.type == intp and y.type == floatp){
    return lisp_valiable(*(long long*)x.value**(double*)y.value);
  }
  if(x.type == floatp and y.type == floatp){
    return lisp_valiable(*(double*)x.value**(double*)y.value);
  }
  cout << "lisp_valiable operator*: BAD VARIABLE TYPE ERROR" << endl;
  exit(1);
}

lisp_valiable operator/(lisp_valiable x,lisp_valiable y){
  if(x.type == intp and y.type == intp){
    return lisp_valiable(*(long long*)x.value / *(long long*)y.value);
  }
  if(x.type == floatp and y.type == intp){
    return lisp_valiable(*(double*)x.value / *(long long*)y.value);
  }
  if(x.type == intp and y.type == floatp){
    return lisp_valiable(*(long long*)x.value / *(double*)y.value);
  }
  if(x.type == floatp and y.type == floatp){
    return lisp_valiable(*(double*)x.value / *(double*)y.value);
  }
  cout << "lisp_valiable operator/: BAD VARIABLE TYPE ERROR" << endl;
  exit(1);
}

lisp_valiable operator%(lisp_valiable x,lisp_valiable y){
  if(x.type==intp and y.type==intp){
    return lisp_valiable(*(long long*)x.value % *(long long*)y.value);
  }
  cout << "lisp_valiable operator%: BAD VARIABLE TYPE ERROR" << endl;
  exit(1);
}

lisp_valiable operator<(lisp_valiable x,lisp_valiable y){
  if(x.type == intp and y.type == intp){
    return lisp_valiable(*(long long*)x.value < *(long long*)y.value);
  }
  if(x.type == floatp and y.type == intp){
    return lisp_valiable(*(double*)x.value < *(long long*)y.value);
  }
  if(x.type == intp and y.type == floatp){
    return lisp_valiable(*(long long*)x.value < *(double*)y.value);
  }
  if(x.type == floatp and y.type == floatp){
    return lisp_valiable(*(double*)x.value < *(double*)y.value);
  }
  cout << "lisp_valiable operator<: BAD VARIABLE TYPE ERROR" << endl;
  exit(1);
}

lisp_valiable operator<=(lisp_valiable x,lisp_valiable y){
  if(x.type == intp and y.type == intp){
    return lisp_valiable(*(long long*)x.value <= *(long long*)y.value);
  }
  if(x.type == floatp and y.type == intp){
    return lisp_valiable(*(double*)x.value <= *(long long*)y.value);
  }
  if(x.type == intp and y.type == floatp){
    return lisp_valiable(*(long long*)x.value <= *(double*)y.value);
  }
  if(x.type == floatp and y.type == floatp){
    return lisp_valiable(*(double*)x.value <= *(double*)y.value);
  }
  cout << "lisp_valiable operator<=: BAD VARIABLE TYPE ERROR" << endl;
  exit(1);
}

lisp_valiable operator>(lisp_valiable x,lisp_valiable y){
  if(x.type == intp and y.type == intp){
    return lisp_valiable(*(long long*)x.value > *(long long*)y.value);
  }
  if(x.type == floatp and y.type == intp){
    return lisp_valiable(*(double*)x.value > *(long long*)y.value);
  }
  if(x.type == intp and y.type == floatp){
    return lisp_valiable(*(long long*)x.value > *(double*)y.value);
  }
  if(x.type == floatp and y.type == floatp){
    return lisp_valiable(*(double*)x.value > *(double*)y.value);
  }
  cout << "lisp_valiable operator>: BAD VARIABLE TYPE ERROR" << endl;
  exit(1);
}

lisp_valiable operator>=(lisp_valiable x,lisp_valiable y){
  if(x.type == intp and y.type == intp){
    return lisp_valiable(*(long long*)x.value >= *(long long*)y.value);
  }
  if(x.type == floatp and y.type == intp){
    return lisp_valiable(*(double*)x.value >= *(long long*)y.value);
  }
  if(x.type == intp and y.type == floatp){
    return lisp_valiable(*(long long*)x.value >= *(double*)y.value);
  }
  if(x.type == floatp and y.type == floatp){
    return lisp_valiable(*(double*)x.value >= *(double*)y.value);
  }
  cout << "lisp_valiable operator>=: BAD VARIABLE TYPE ERROR" << endl;
  exit(1);
}

lisp_valiable operator==(lisp_valiable x,lisp_valiable y){
  if(x.type == intp and y.type == intp){
    return lisp_valiable(*(long long*)x.value == *(long long*)y.value);
  }
  if(x.type == floatp and y.type == intp){
    return lisp_valiable(*(double*)x.value == *(long long*)y.value);
  }
  if(x.type == intp and y.type == floatp){
    return lisp_valiable(*(long long*)x.value == *(double*)y.value);
  }
  if(x.type == floatp and y.type == floatp){
    return lisp_valiable(*(double*)x.value == *(double*)y.value);
  }
  cout << "lisp_valiable operator==: BAD VARIABLE TYPE ERROR" << endl;
  exit(1);
}


class lisp_cons{
public:
  lisp_valiable car;
  lisp_valiable cdr;
  lisp_cons(lisp_valiable x,lisp_valiable y){
    car = x;
    cdr = y;
  }
  lisp_cons(){
    car = lisp_valiable();
    cdr = lisp_valiable();
  }
};

lisp_valiable cons(lisp_valiable x,lisp_valiable y){
  return lisp_valiable(new lisp_cons(x,y));
}

lisp_valiable& car(lisp_valiable x){
  if(x.type!=consp){
    cout << "car: BAD VARIABLE TYPE ERROR" << endl;
    exit(1);
  }
  return ((lisp_cons*)x.value)->car;
}

lisp_valiable& cdr(lisp_valiable x){
  if(x.type!=consp){
    cout << "cdr: BAD VARIABLE TYPE ERROR" << endl;
    exit(1);
  }
  return ((lisp_cons*)x.value)->cdr;
}

const lisp_valiable nil = lisp_valiable(nilp);
const lisp_valiable t = lisp_valiable(tp);


lisp_valiable null(lisp_valiable x){
  if(x.type==nilp)return t;
  return nil;
}

lisp_valiable read_int(){
  long long x;
  cin >> x;
  return lisp_valiable(x);
}

lisp_valiable read_string(){
  string x;
  cin >> x;
  return lisp_valiable(x);
}

lisp_valiable lisp_princ(lisp_valiable x){
  if(x.type==intp){
    cout << *(long long*)x.value;
    return t; 
  }
  if(x.type==floatp){
    cout << *(double*)x.value;
    return t;
  }
  if(x.type==stringp){
    cout << (*((string*)x.value));
    return t;
  }

  cout << x.type << endl;
  cout << "lisp_princ:This is not implemented" << endl;
  return t;
}

lisp_valiable lisp_list(vector<lisp_valiable> args){
  reverse(args.begin(),args.end());
  lisp_valiable res;
  for(lisp_valiable val:args){
    res = cons(val,res);
  }
  return res;
}

lisp_valiable lisp_nthcdr(lisp_valiable n,lisp_valiable x){
  if(n.type!=intp){
    cout << "lisp_nthcdr: INVALID VALIABLE TYPE" << endl;
    exit(1);
  }
  long long N = *(long long*)n.value;
  for(int i=0;i<N;++i){
    x = cdr(x);
  }
  return x;
}

lisp_valiable& lisp_nth(lisp_valiable n,lisp_valiable x){
  if(n.type!=intp){
    cout << "lisp_nthcdr: INVALID VALIABLE TYPE" << endl;
    exit(1);
  }
  return car(lisp_nthcdr(n,x));
}

function<lisp_valiable(lisp_valiable)> func_get(lisp_valiable x){
  if(x.type!=functionp){
    cout << "func_get: INVALID VALIABLE TYPE" << endl;
    exit(1);
  }
  return *(function<lisp_valiable(lisp_valiable)>*)x.value;
}

lisp_valiable lisp_mapcar(lisp_valiable func,lisp_valiable lst){
  function<lisp_valiable(lisp_valiable)> f = func_get(func);
  vector<lisp_valiable> res;
  while(lst.type==consp){
    res.emplace_back(f(lisp_list({car(lst)})));
    lst = cdr(lst);
  }
  return lisp_list(res);
}

lisp_valiable lisp_make_array(lisp_valiable sizes){
  lisp_valiable res;
  function<lisp_valiable(lisp_valiable&,lisp_valiable)> func =
    [&](lisp_valiable& x,lisp_valiable sizes)->lisp_valiable{
      if(sizes.type==nilp){
        return t;
      }
      lisp_valiable n = car(sizes);
      lisp_valiable next = cdr(sizes);
      if(n.type!=intp){
        cout << "lisp_make_array: INVALID SIZES TYPE" << endl;
        exit(1);
      }
      long long N = *(long long*)n.value;
      x = lisp_valiable(vector<lisp_valiable>(N));
      for(lisp_valiable &y:*(vector<lisp_valiable>*)x.value){
        func(y,next);
      }
      return t;
    };
  func(res,sizes);
  return res;
}

lisp_valiable &lisp_aref(lisp_valiable &x,lisp_valiable sizes){
  if(sizes.type==nilp)return x;
  lisp_valiable n = car(sizes);
  if(x.type!=vectorp){
    cout << "lisp_aref: INVALID X TYPE" << endl;
    exit(1);
  }
  if(n.type!=intp){
    cout << "lisp_aref: INVALID SIZES TYPE" << endl;
    exit(1);
  }
  long long N = *(long long*)n.value;
  lisp_valiable &next_x = (*(vector<lisp_valiable>*)x.value)[N];
  lisp_valiable next_sizes = cdr(sizes);
  return lisp_aref(next_x,next_sizes);
}
int main(){
[&]()->lisp_valiable{
lisp_valiable N = read_int();
return [&]()->lisp_valiable{
lisp_valiable ANSES = lisp_make_array(lisp_list({N}));
[&]()->lisp_valiable{
lisp_valiable I = lisp_valiable(0);
while((lisp_valiable(((I>=N).type!=nilp))).type==nilp){
lisp_aref(ANSES,lisp_list({I})) = lisp_valiable(0);
I = (I + lisp_valiable(1));
}
return nil;
}();
[&]()->lisp_valiable{
lisp_valiable I = lisp_valiable(0);
while((lisp_valiable(((I>=(N - lisp_valiable(1))).type!=nilp))).type==nilp){
[&]()->lisp_valiable{
lisp_valiable P = (read_int() - lisp_valiable(1));
return lisp_aref(ANSES,lisp_list({P})) = (lisp_aref(ANSES,lisp_list({P})) + lisp_valiable(1));
}();
I = (I + lisp_valiable(1));
}
return nil;
}();
return [&]()->lisp_valiable{
lisp_valiable I = lisp_valiable(0);
while((lisp_valiable(((I>=N).type!=nilp))).type==nilp){
lisp_princ(lisp_aref(ANSES,lisp_list({I})));
lisp_princ(lisp_valiable((string)"\n"));
I = (I + lisp_valiable(1));
}
return nil;
}();
}();
}();
return 0;
}

Measured memory_bytes: 109892