USACO 2016 February Contest, Bronze Problem 2. Circular Barn

I am trying to solve this problem and I just can’t get all the test cases correct. I only get the test cases 1 to 7. The way I solve this question is to try all the cases and find the minimum. If you don’t get how I solve the question, I will write my code below. Could you tell me what is the problem with my code?

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int N;
int r1[2000];
int r2[2000];
int num[2000];

int cases(int i){
    int ans=0;
    if(i%2!=0){
        r2[0] = r1[N-1];
        for(int j = 0; j < N-1; j++){
            r2[j+1] = r1[j];
        }
        for(int j = 0; j < N; j++){
            ans+=j*r2[j];
        }
    }
    else{
        r1[0] = r2[N-1];
        for(int j = 0; j < N-1; j++){
            r1[j+1] = r2[j];
        }
        for(int j = 0; j < N; j++){
            ans+=j*r1[j];
        }
    }
    return ans;
}

int main(){
    freopen("cbarn.in", "r", stdin);
	freopen("cbarn.out", "w", stdout);
    cin >> N;
    for(int i = 0; i < N; i++){
        num[i]=i;
        cin >> r1[i];
    }
    int ans = 999999;
    for(int i = 1; i < N+1; i++){
        ans = min(ans, cases(i));
    }
    cout << ans;
    return 0;
}

^