#include <iostream>
#include <cstdio>
#include <windows.h>
#include <pthread.h>
struct t_param
{
int x;
pthread_mutex_t * lock;
};
void * print(void * arg)
{
t_param * args = (t_param*)arg;
int & x = args->x;
Sleep(x * 3);
pthread_mutex_lock(args->lock);
std::cout << x << std::endl;
pthread_mutex_unlock(args->lock);
}
int main()
{
int n;
std::cin >> n;
int a[n];
pthread_t ID[n];
pthread_mutex_t IO_Lock;
pthread_mutex_init(&IO_Lock, NULL);
t_param arg[n];
for (int i = 0; i < n; ++i)
{
std::cin >> a[i];
arg[i] = (t_param){a[i], &IO_Lock};
pthread_create(ID + i, NULL, print, &arg[i]);
}
for (int i = 0; i < n; ++i)
{
pthread_join(ID[i], NULL);
}
return 0;
}