```
public int maxRotateFunction(int[] A) {
int sum = IntStream.of(A).sum();
int initial = 0;
int len = A.length;
for (int i = 0; i < len; i++) {
initial += i * A[i];
}
int max = initial;
for (int i = len - 1; i >= 0; i--) {
initial += sum - len * A[i];
max = Math.max(max, initial);
}
return max;
}
```

No explanation needed.