#include #include // Capture the pipe of array contents, first number is the size int main() { int s; int res = scanf("%d", &s); if (res != 1) { fprintf(stderr, "Error reading size\n"); return 1; } int *array = malloc(sizeof(int) * s); for (int i = 0; i < s; i++) { res = scanf("%d", &array[i]); if (res != 1) { fprintf(stderr, "Error reading array element\n"); free(array); return 1; } } for (int j = 0; j < s; j++) { int key = array[j]; int i = j - 1; while (i >= 0 && array[i] > key) { array[i + 1] = array[i]; i -= 1; } array[i + 1] = key; } free(array); return 0; }