```
int maxRotateFunction(int* A, int ASize) {
if (ASize == 0) return 0;
int i,sum_p=0,sum=0;
for(i=0;i<ASize;++i){
sum_p+=i*A[i];
sum += A[i];
}
int max = sum_p;
for (i=1;i<ASize;++i){
int tmp = sum_p-(sum-A[i-1>=0?(i-1):(ASize-1)])+A[i-1>=0?(i-1):(ASize-1)]*(ASize-1);
sum_p = tmp;
if (tmp>max) max = tmp;
}
return max;
}
```