Runtime error

#include
#include<stdio.h>
int main()
{
int n,k=0,i=0,p,sum=0,first;
scanf("%d",&n);
int* a=new int[n];
if(n==1||n==2)
{
k=1;
goto b;
}
do{
a[i]=i+1;
sum+=a[i];
k++;
if(sum==n)
goto b;
if(sum>n)
{
p=sum-n;
for(int q=0;q<k;q++)
{
if(p==a[q])
{
first=q;
break;
}
}
for(int j=first;j<k-1;j++)
a[j]=a[j+1];
k–;
sum-=a[first];
}
if(sum==n)
goto b;
i++;
}while(i<n);
b:printf("%d",k);
return 0;
}

I am getting error why?

//