#include <cstdio>
#include <vector>
using namespace std;
const int maxn = 10010;
struct node{int data;node* l;node* r;
};
int n,cur=0;
vector<int> ori,pre,mirror;
void insert(node* &root, int data){if(root == NULL){root = new node;root->data = data;root->l = NULL;root->r = NULL;return;}if(root->data > data) insert(root->l, data);else insert(root->r, data);
}
void preOrder(node* root){if(root == NULL) return;pre.push_back(root->data);preOrder(root->l);preOrder(root->r);
}
void mirrOrder(node* root){if(root == NULL) return;mirror.push_back(root->data);mirrOrder(root->r);mirrOrder(root->l);
}
void posOrder(node* root){if(root == NULL) return;posOrder(root->l);posOrder(root->r);printf("%d", root->data);if(cur < n-1){printf(" ");cur++;}
}
void mirrPosOrder(node* root){if(root == NULL) return;mirrPosOrder(root->r);mirrPosOrder(root->l);printf("%d", root->data);if(cur < n-1){printf(" ");cur++;}
}
int main() {scanf("%d", &n);node* root = NULL;int d;for(int i = 0; i < n; i++){scanf("%d", &d);insert(root, d);ori.push_back(d);}preOrder(root);mirrOrder(root);if(pre == ori){printf("YES\n");posOrder(root);printf("\n");}else if(mirror == ori){printf("YES\n");mirrPosOrder(root);printf("\n");}else{printf("NO\n");}return 0;
}