#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef struct Node {
int data;
struct Node* node;
}Node;
Node* init(Node*first) {
first = (Node*)malloc(sizeof(Node));
first->node = NULL;
return first;
}
void creatlist(Node* first) {
Node* p;
int j = 0, i = 1;
while (i) {
scanf_s("%d", &j);
if (j != -1) {
p = (Node*)malloc(sizeof(Node));
p->data = j;
p->node = first->node;
first->node = p;
}
else {
i = 0;
}
}
}
void min(Node* first) {
int temp = first->node->data;
Node* p = first->node, * q = first->node;
p = p->node;
while (p->node!=NULL) {
if (temp > p->data) {
temp = p->data;
p = p->node;
}
else
p = p->node;
}
if (p->node ==NULL) {
if (temp > p->data)
temp = p->data;
}
while (q->node != NULL) {
if (q->data != temp) {
p = q;
q = q->node;
}
}
printf("%d", q->data);
p->node = q->node;
q->node = first->node;
first->node = q;
}
void output(Node* first) {
Node* p = first;
while (p->node!=NULL) {
printf("%d", p->node->data);
p = p->node;
}
}
int main() {
Node* first = (Node*)malloc(sizeof(Node));
first->node = NULL;
if (first == 0)
printf("yes");
creatlist(first);
min(first);
output(first);
return 0;
}