#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
void printarray(int *arr, int n)
{
for (int i = 0; i < n; i++)
{
printf("%d ", arr[i]);
}
printf("\n");
}
void nge(int *arr, int n)
{
for (int i = 0; i < n; i++)
{
int j;
check:
j = i + 1;
while(j < n)
{
if (arr[j] > arr[i])
{
printf("%d %d\n", arr[i], arr[j]);
i++;
goto check;
}
j++;
}
printf("%d %d\n", arr[i],-1);
}
}
int main()
{
int n, a, b;
printf("enter the total elements of array\n");
scanf("%d", &n);
int *arr = (int *)malloc(n * (sizeof(int)));
for (int i; i < n; i++)
{
printf("enter the element %d :\n", i + 1);
scanf("%d", &arr[i]);
}
printarray(arr, n);
nge(arr, n);
return 0;
}