So i have this program that takes in user input and stores them into an array and then prints them, removes duplicates, and sorts in ascending order. The user can also stop by inputting a sentinel value (in this case -1). But i am also supposed to ignore any negative value besides -1. When i input any other negative value into the program it messes up. How would i go about ignoring the negative values?

Code:
#include<stdio.h>

int main()
{
    int input, nums[20], i, j, k, temp, count=0, count2=0;

    for(i=0;i<20;i++)
    {
        
        printf("Enter any positive integer (Enter -1 to stop): ");
        scanf("%i", &input);
        nums[i]=input;
        count++;
        if(input==-1)
        {
            nums[i]=nums[i-1];
            count--;
            i=20;
        }

        else if(input<-1)
        {
            nums[i]=nums[i-1];
            count--;
        }
        
    }

    printf("\nOriginal list: ");
    
    for(i=0;i<count;i++)
    {
        printf("%i ", nums[i]);
    }

    printf("\nDuplicates removed: ");
    for(i=0;i<count;i++)
    {
        for(j=i+1;j<count;)
        {
            if(nums[i]==nums[j])
            {
                for(k=j;k<count;k++)
                    nums[k]=nums[k+1];
                    count--;
            }
            else
                j++;
        }
    }

    for (i=0;i<count;i++)
        printf("%i ", nums[i]);

    printf("\nAscending order with duplicates removed: ");
    for(j=0;j<count-1;j++)
        for(i=0;i<count-1;i++)
        {
            if(nums[i]>nums[i+1])
            {
                temp = nums[i];
                nums[i] = nums[i+1];
                nums[i+1] = temp;
            }
        }

    for(i=0;i<count;i++)
        printf("%i ",nums[i]);

    return 0;
}