Can u help me with this problem below is my solution

/Given an array, only rotation operation is allowed on array. We can rotate the array as many times as we want. Return the maximum possible of summation of iarr[i].*/
#include
using namespace std;
void rotation(int *arr,int n)
{
int temp=arr[0],i;
for(i=0;i<n-1;i++)
{
arr[i]=arr[i+1];
}
temp = arr[i];
}
void ans(int arr,int n,int answer)
{
for(int i=0;i<n;i++)
{
int answer=0;
answer=answer+i
arr[i];

	//sum = sum + answer;
}
int maxsum=0;
if(answer>maxsum)
	{
		maxsum=answer;
		rotation(arr,n);
		ans(arr,n-1,answer);
	}
else
cout<<maxsum;

}
int main()
{
int n,answer;
cin>>n;
int *arr=new int[n];
for(int i=0;i<n;i++)
{
arr[i]=i+1;
}
ans(arr,n,answer);

}

@supratik260699 hey supratik your approach looks wrong
use this method
The idea is to compute value of a rotation using value of previous rotation. When we rotate an array by one, following changes happen in sum of i*arr[i].

  1. Multiplier of arr[i-1] changes from 0 to n-1, i.e., arr[i-1] * (n-1) is added to current value.
  2. Multipliers of other terms is decremented by 1. i.e., (cum_sum – arr[i-1]) is subtracted from current value where cum_sum is sum of all numbers.