Subsequence Summing to Seven code problems

So I was trying to solve the USACO Silver problem that I listed in the title. I got all of the test cases right except the last 2. I tried to see the values in the test cases but they were too large for me to grasp. Can you please tell me the flaw in my code?(Please don’t tell me how to solve it. I want to do that by myself). Thanks!!

#include <bits/stdc++.h>
using namespace std;
int n;
ifstream fin("");
ofstream fout("div7.out");
int main(){
    fin >> n;
    int id[n];//the id's
    for(int i=0;i<n;i++){
    int prefix[n+1];//prefix array
    for(int i=1;i<n+1;i++)prefix[i]=prefix[i-1]+id[i-1];
    for(int j=n;j>=0;j--){//size of the subarray we are testing
        for(int i=0;i<n+1;i++){
            if(i+j>n)break;//if the index is outside of the array, skip
            int temp=prefix[i+j]-prefix[i];//sum of the index's
                fout << j <<"\n";//we have the max value, so give it
                return 0;
    fout << 0 << "\n";//default
    return 0;

integer overflow? values can be up to 10^9

Thank you!! That was the problem. I’m just not used to using long longs.