void prepare(int *x) {
    fo(i,1,n) data[i]=x[i];
    sort(data+1,data+n+1);
    int m=unique(data+1,data+n+1)-data-1;
    fo(i,1,n) x[i]=lower_bound(data+1,data+m+1,x[i])-data;
}