int RemoveDuplicates(int A[], int n)
{
if (n<1)return 0;
int i = 1;
int j = 0;
int val = A[j];
while(++j < n)
if(val != A[j])
val = A[i++] = A[j];
return i;
}
#include "stdio.h"
int main(int argc, char** argv)
{
int a[] = {-1,-1,2,2,3,3,3,5,5,5,5,5,7,7,7,7,7,7,7};
int count = RemoveDuplicates(a, 19);
for (int i = 0; i < count; ++i)
printf("%d, ", a[i]);
return 0;
}