can anyone tell why I getting the wrong answer?

My Code:

#include

#include

using namespace std;

int main()

{

int n,k;

```
cin>>n>>k;
long long int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
int max=*max_element(arr,arr+n);
while(k--)
{
for(int i=0;i<n;i++)
{
arr[i]=max-arr[i];
}
max=*max_element(arr,arr+n);
}
for(int i=0;i<n;i++)
cout<<arr[i]<<" ";
return 0;
```

}