Help me in solving AOCC10 problem

My issue

According to my calculation, it should work. But it isn't. I can't figure out the problem in logic. Please help me to find the fault.

My code

// Update the code below to solve the problem

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

int main() 
{
	int t;
        cin >> t;
	
	while(t--)
	{
	    int N;
	    cin >> N;
	    int A[N],SS[10],total_sat_sun =0, total_holiday=0;
	    for(int i=0; i < N; i++)
	    {
	        cin >> A[i];
	    }
	    for(int i =1; i<=30; i++) // counting total saturday & sunday
	    {
	       if(i%7==0) // checking if it's sunday
	       {
	               total_sat_sun+=1;
	               SS[i] = i;
	       }
	       else{
	             for(int j =6; j<=30; j+=7) // checking if it's saturday
	             {
	                  if(i==j) 
	                  {
	                          total_sat_sun+=1;
	                          SS[i-1] = i;
	                  }
	             }
	       }
	    }
	    sort(A, A+N); //sorting the festival days 
	    total_holiday+=total_sat_sun; //Sundays and Saturdays are also holidays
	    for(int j=0; j<N; j++)
	    {
	       for (int k =6; k<=30; k=k+7)
	       {
	                 if(A[j] != SS[j] || A[j] != SS[j+1]) total_holiday++;  //checking if the festival day is saturday/sunday
	       }
	    }
	    cout<<total_holiday<<endl;
	  }
	  return 0;
}
	

Learning course: Solve Programming problems using C++
Problem Link: CodeChef: Practical coding for everyone