Simple o(n) C++ solution 
cpp\nclass Solution {\npublic:\n    int bestRotation(vector<int>& A) \n    {\n        int N = A.size();\n        vector<int>AddPoint(N+1,0);\n        vector<int
```cpp\nclass Solution {\npublic:\n    int bestRotation(vector<int>& A) \n    {\n        int N = A.size();\n        vector<int>AddPoint(N+1,0);\n        vector<int>MinusPoint(N+1,0);\n        \n        int count=0;\n        for (int i=0; i<A.size(); i++)\n        {\n            if (i>=A[i]) count++;            \n            if (i>=A[i])\n            {\n                MinusPoint[i-A[i]+1]+=1;    // for this A[i] element, rotate i-A[i]+1 times will change the point from 1 to 0\n                AddPoint[i+1]+=1;           // but at the i+1 move, the point will go back from 0 to 1\n            }\n            else\n            {\n                AddPoint[i+1]+=1;               // for this A[i] element, rotate i+1 times will change the point from 0 to 1\n                MinusPoint[i+1+N-A[i]]+=1;    // but after another N-A[i] move, the point will go back from 1 to 0\n            }                \n        }\n                    \n        int result = count;\n        int K=0;        \n        \n        for (int k=1; k<N; k++)\n        {\n            count+=AddPoint[k];\n            count-=MinusPoint[k];\n                        \n            if (count>result)\n            {\n                result = count;\n                K=k;\n            }\n        }        \n        return K;\n    }\n};\n```
[]