int totalMoney(int n) {
int k=n/7; //total weeks
// 1st week -> 1+2+3..+7=28
//2nd week -> 2+3+4..+8=35
int sum=(k*(2*28+(k-1)*7))/2;
for(int day=0;day<n%7;day++)
sum+=(k+1)+day;
return sum;
}