#include

using namespace std;

int counting(long int[],unsigned long int);

int main()

{

unsigned long int n;

cin>>n;

long int* a=new long int[n];

for(int i=0;i<n;i++)

cin>>a[i];

unsigned long int x;

cin>>x;

int sum=0;

int count=0;

count=counting(a,n);

while(count>=x)

{

for(int i=0;i<n;i++)

a[i]=a[i]+1;

count=counting(a,n);

sum+=x;

```
}
for(int i=0;i<n;i++)
{
if(a[i]<0)
sum-=a[i];
}
cout<<sum;
}
int counting(long int a[],unsigned long int n)
{
int count=0;
for(int i=0;i<n;i++)
if(a[i]<0)
count++;
return count;
}
```