#include <stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int a[7];
    for (int i=0;i<7;i++)
    scanf("%d",&a[i]);
    int k=0;int i=0;
    while (k<n)
    {
        k+=a[i];
        i++;
        if (i==7)
        i=0;
    }
    if(i==0)
        printf("7");
    else
     printf("%d",i);
}

#include<stdio.h>
int main()
{
    int i,n,arr[10],flag=0,day;
    scanf("%d",&n);
    for(i=1;i<=7;i++)
    {
        scanf("%d",&arr[i]);
    }
    while(1)
    {
        for(i=1;i<=7;i++)
        {
            n=n-arr[i];
            if(n<=0)
            {
                day=i;
                flag=1;
                break;
            }
        }
        if(flag==1)
        {
            break;
        }
    }
    printf("%d\n",day);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int pages,i;
    scanf("%d",&pages);
    int day[10];
    for(i=1;i<=7;i++){
        scanf("%d",&day[i]);
    }
    int read=0;
    int save;
    int flag=0;
    int j;
    while(read<pages){
        for(j=1;j<=7;j++){
            read=read+day[j];
            if(read>=pages && flag==0){
                save=j;
                flag=1;
                break;
            }
        }
    }

        printf("%d",save);

    return 0;
}

#include<stdio.h>
int main()
{
    int n,week[7],i,j=0;
    scanf("%d",&n);
    for(i=0;i<7;i++)
        scanf("%d",&week[i]);
    while(n>0)
    {
        n=n-week[j];
        j++;
       if(j==7 && n<=0) break;
        if(j>6) j=0;
    }
    printf("%d",j);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include<string.h>
// skdjfklsdjfkldsklj
int sum[8];
int main()
{
	int n, w;
	scanf("%d", &n);
	for (int i = 1; i < 8; i++)
	{
		scanf("%d", &w);
		sum[i] = sum[i - 1] + w;
	}
	n %= sum[7];
	if (n == 0) n = sum[7];
	for (int i = 1; i < 8; i++)
	{
		if (sum[i] >= n)
		{
			printf("%d\n", i);
			return 0;
		}
	}
}

#include<stdio.h>
int main(){
    int n,pages[7],read=0,day=0;
    scanf("%d",&n);
    for(int i=0;i<7;i++){
        scanf("%d",&pages[i]);
    }
    while(1){
    for(int i=0;i<7;i++){
        read+=pages[i];
        if(read>=n){ day=i+1;break;}

    }
      if(day!=0) break;
    }
    printf("%d",day);
}

#include<stdio.h>
#include<stdlib.h>
int main ()
{
    int n,i,a[8];
    scanf("%d",&n);
    for(i=0;i<7;i++)
    {
        scanf("%d",&a[i]);
    }
    int s=0,t=0;
    while(s<n)
    {
    for(i=0;i<7;i++)
    {
       s=s+a[i];
       if(s>=n && a[i]!=0)
            {
                printf("%d",i+1);
                break;
            }
    }
    }
    return 0;

}

#include<stdio.h>
int main(){
    int totpag=0,lu=0,ma=0,mi=0,ju=0,vi=0,sa=0,dom=0,dia=0,x=0;
    scanf("%d",&totpag);
    scanf("%d%d%d%d%d%d%d",&lu,&ma,&mi,&ju,&vi,&sa,&dom);
    do{
        dia++;
        if((dia%7)==0) totpag=totpag-dom;
        else if((dia%7)==1) totpag=totpag-lu;
        else if((dia%7)==2) totpag=totpag-ma;
        else if((dia%7)==3) totpag=totpag-mi;
        else if((dia%7)==4) totpag=totpag-ju;
        else if((dia%7)==5) totpag=totpag-vi;
        else if((dia%7)==6) totpag=totpag-sa;
    }while(totpag>0);
    if (dia%7==0){dia=7;}
    else dia=dia%7;
    printf("%d",dia);
}

#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int days[7], j, sum = 0;
	for (j = 0; j < 7; j++)
		scanf("%d", &days[j]);
	while (1)
	{
		for (j = 0; j < 7; j++)
		{
			if (n > 0)
				n -= days[j];
			if (n <= 0)
			{
				printf("%d\n", j + 1);
				return 0;
			}
		}
	}
}

#include <stdio.h>

int main() {

    int pages, i;
    scanf("%d", &pages);

    int dayValues[7];
    for (i = 0; i <= 6; i++) {
        scanf("%d", &dayValues[i]);
    }

    int currentPages = 0, currentDay = 0;

    while (1) {

        currentPages += dayValues[currentDay];

        if (currentPages >= pages) {
            printf("%d", currentDay + 1);
            break;
        } else {
            currentDay++;
        }

        if (currentDay == 7) {
            currentDay = 0;
        }
    }
}

#include <stdio.h>

int main()
            {         int n,sum=0;

                 scanf("%d",&n);
                  int a[7];
            for(int i=0;i<7;i++)
             {   scanf("%d",&a[i]);
                   sum+=a[i];
            //   printf("%d ",sum);
             }
            sum=n%sum;
                   if(sum)
               for(int i=0;i<7;i++)
                    {    sum-=a[i];
                 //  printf("hi %d %d ",a[i],sum);
                           if(sum<=0)
                        {printf("%d\n",i+1);
                          break;}}
                else
                {      for(int i=6;i>-1;i--)
                   if(a[i])
                 {    printf("%d",i+1);
                     break;}}
    return 0;
}/*
int s=0,l=0,x;          char a[10];
                            for(int i=0;scanf("%c",&a[i])!=EOF&&i<100;x++,i++)
                             {           printf("%c",a[i]);
                                 if(a[i]<97&&a[i]>64)
                                   l++;
                                    else
                                    s++;}
                       if(s<l)
                     {  for(int i=0;i<x;i++)
                          printf("%c",a[i]);}
                     else
                     {  for(int i=0;i<x;i++)
                          printf("%c",a[i]);}*/

#include<stdio.h>

int main()
{
	int n;
	scanf("%d",&n);
	int pages[7];
	for (int i=0;i<7;i++)
		scanf("%d",&pages[i]);
	int temp=n, ans=0, flag=0;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<7;j++)
		{
			temp-=pages[j];
			if (temp<=0)
			{
				ans=j+1;
				flag=1;
				break;
			}
		}
		if (flag==1)
			break;
	}
	printf("%d\n",ans);
	return 0;
}

#include<stdio.h>
#include<string.h>
int main()
{
    int n,i=0;
    scanf("%d",&n);
    int a[7],s=0;
    for(int i=0;i<7;i++)
    {
        scanf("%d",&a[i]);
    }
    while(i>=0)
    {
        if(i<7)
        {
            s+=a[i];
            if(s>=n)
            {
                printf("%d",i+1);
                break;
            }
        }
        else if(i>=7)
        {
            int p=(i%7);
            s+=a[p];
            if(s>=n)
            {
                printf("%d",p+1);
                break;
            }
        }
        i++;
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int t[100];
    int n,i,somme;
    somme=0;

    scanf("%d",&n);
    for (i=1;i<=7;i++)
    {
            scanf("%d",&t[i]);
    }

    do
    {
        for (i=1;i<=7;i++)
        {
            somme=somme+t[i];

            if (somme>=n)
            {
                printf("%d",i);
                exit(0);
            }

        }

    }while(somme<n);
    printf("%d",i);

}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
	int pages;
	int mo,tu,we,th,fr,sa,su;
	scanf("%d",&pages);
	int day[8];
	for(int i=0;i<7;i++){
		scanf("%d",&day[i]);
	}

	int temp=1;

	while(pages > 0){
		if(temp==8) temp=1;

		pages-=day[temp-1];

		temp++;
	}
	printf("%d",temp-1);

	return 0;
}

#include<stdio.h>
int main()
{
	int n,arr[7],cnt=0,book_pg=0,i=0;
	scanf("%d",&n);
	for(i=1;i<=7;i++)
		scanf("%d",&arr[i]);
	for(i=1;i<8;i++)
	{
		book_pg=book_pg+arr[i];
	//	printf("%d",book_pg);
		cnt++;
		if(book_pg>=n)
		break;

		if(i==7)
		{

		i=0;
		continue;
		}

	//	printf("%d\n",i);
	}
	printf("\n%d",i);
	return 0;

}

#include<stdio.h>
int main()
{
      int n,i;
      scanf("%d",&n);
      int a[7],total=0;
      for(i=0;i<7;i++)
      {
            scanf("%d",&a[i]);
            total+=a[i];
      }
      int x;
      x=n/total;
      x=x*total;
      if(x<n)
      {
            for(i=0;i<7;i++)
            {
                  x+=a[i];
                  if(x>=n) break;
            }
            printf("%d",i+1);
      }
      else if(x==n)
      {
            x=n/total;
            x=(x-1)*total;
            for(i=0;i<7;i++)
            {
                  x+=a[i];
                  if(x>=n) break;
            }
            printf("%d",i+1);
      }

      return 0;
}

#include"stdio.h"
int main()
{
    int n;
    scanf("%d",&n);
    int num[7];  // 0 is monday, 6 is sunday
    int i;
    for(i=0;i<7;i++)
    scanf("%d",&num[i]);
    int sum=n,flag=0,j;
    while(flag==0)
    {
        for(j=0;j<7;j++)
        {
            sum-=num[j];
            if(sum<=0) { flag=j+1; break;}
        }

    }
   printf("%d",flag);
   return 0;
}

#include<stdio.h>
int get_lcm(int x,int y);
int main(){
int n,i,sum;
sum=0;
int day_pages[7];
scanf("%d",&n);
for(i=0;i<7;i++){
    scanf("%d",&day_pages[i]);
}
begin:
for(i=0;i<7;i++){
      sum+= day_pages[i];
      if (!(sum<n)){
        printf("%d\n",i+1);
        break;
      }
      if(i==6 && sum<n){
        goto begin;
      }
}

return 0;
}

#include <stdio.h>
int main()
{
    int n, ara[7], i;
    scanf("%d", &n);
    for(i = 0; i <7; i++){
        scanf("%d", &ara[i]);
    }
    i = 0;
    while(n>0){
        n = n -ara[i];
        i = i + 1;
        if(i==7){
            i = 0;
        }
    }
    if(i == 0){
        printf("7");
        return 0;
    }
    printf("%d", i);
    return 0;
}

// C program for insertion sort
#include <stdio.h>
#include <math.h>
#include<string.h>
#include<stdlib.h>
int maxi(int n,int m)
{
    return n>m?n:m;
}
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for(i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for(j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the sub-array
  of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        int m = l+(r-l)/2; //Same as (l+r)/2, but avoids overflow for large l and h
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);
        merge(arr, l, m, r);
    }
}

int main()
 {
     int i=0,j=0,n,m,x,y,z,r,flag=0,sum=0,arr[8],x1,x2,y1,y2;
    scanf("%d",&n);
    for(i=0;i<7;i++)
    {
        scanf("%d",&arr[i]);
    }
    while(sum<n)
    {
        i=0;
        for(i=0;i<7;i++)
        {
            sum+=arr[i];
            if(sum>n)
            {
                flag=1;
                break;
            }
            if(sum==n)
            {
                flag=2;
                break;
            }
            if(flag>=1)
                break;
        }

    }
    if(flag>=1)
    printf("%d",i+1);
    return 0;
 }

#include<stdio.h>
int main()
{
    int n,i,ara[7];
    scanf("%d", &n);

    for(i=0;i<7;i++)
    {
        scanf("%d", &ara[i]);
    }
    int s =0;
    for(i=0;s<n;i++)
    {
        if(i==7)
            i=0;
        s = s+ ara[i];

    }
    printf("%d\n", i);
}

#include<stdio.h>
#include<stdlib.h>

int main(){
 int tab[8];
 int i,j,n;
 scanf("%d",&n);
 for(i=1;i<=7;i++)
    scanf("%d",&tab[i]);
 while(n>=0){
    for(i=1;i<=7;i++){
        n-=tab[i];
        if(n<=0){
            printf("%d",i);
            return 0;
        }
    }
 }

}

#include <stdio.h>

int main() {
	int i, n;
	static int a[7];

	scanf("%d", &n);
	for (i = 0; i < 7; i++)
		scanf("%d", &a[i]);
	for (i = 0; ; i = (i + 1) % 7) {
		n -= a[i % 7];
		if (n <= 0) {
			printf("%d\n", i + 1);
			break;
		}
	}
	return 0;
}

#include <stdio.h>

int main()
{
	int n;
	scanf("%d",&n);
	int s[7];
	for(int i=0; i<7; i++){
		scanf("%d",&s[i]);
	}

	int sum=s[0],i=1;
	while(sum<n){
		sum+=s[i];
		if(i==6){ i=0;}
		else{i++;}
	}
	if(i==0) printf("7");
	else{
	printf("%d",i);}

	return 0;
}

#include<stdio.h>
int main()
{
	int number,i,j=0,array[7],sum=0,count=0;
	scanf("%d",&number);
	for(i=0;i<7;i++)
	{
		scanf("%d",&array[i]);
		sum=sum+array[i];
	}

if (number%sum==0)
{

	while(number)
	{
		for (i = 0; i < 7; i++)
		{
			if(number>0)
			{
				number=number-array[i];
				count++;
			}
		}
		j++;
	}
}
else
{	number=number%sum;
	j=1;
	for (i = 0; i < 7; i++)
	{
		if(number>0)
		{
			number=number-array[i];
			count++;
		}
	}
}
	printf("%d",count-((j-1)*7));
	return 0;
}

#include<stdio.h>
int main()
{
    int n,m,a,b,c,d;
    scanf("%d",&n);
    int week[7]={0};
    for(a=0;a<7;a++)
        {
            scanf("%d",&week[a]);
        }
    for(c=0;0<n;c++)
        {
            n-=week[c%7];
        }
        if(c%7!=0)
    printf("%d",c%7);
    else
    printf("7");
return 0;
}

//SORU xx
//PROGRAM C
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#include<time.h>
#include<ctype.h>
//#include<math.h>
#define scn(x) fscanf(in,"%d",&x);
#define prn(x) fprintf(out,"%d\n",x);
#define prn2(x) fprintf(out,"%d",x);
#define line() fprintf(out,"\n");
#define wait system("PAUSE");
#define scn2(x,y) scn(x);scn(y);
FILE *in,*out;
void dosya(){
		/*in=fopen("girdi.in","r");*/in=stdin;
		/*out=fopen("cikti.out","w");*/out=stdout;
}
int N,gun[10];
void oku(){
	scn(N);
	int i;
	for(i=1; i<=7; i++)
		scn(gun[i]);
}
void coz(){
	int yer=1,top=0;
	while(1){
		if(N<=0) break;
		top++;
		N-=gun[yer++];
		if(yer==8) yer=1;
	}
	if(top%7==0) fprintf(out,"7");
	else prn(top%7);
}
int main(){
	dosya();
	oku();
	coz();
	return 0;
}

#include <stdio.h>

int main(){
	int n,i;
	int a[8];
	int count=0;
	int day;
	scanf("%d",&n);
	for(i=1;i<=7;i++){
		scanf("%d",a+i);
		//count+=a[i];
	}
	while(n>0){
		for(i=1;i<=7;i++){
			n-=a[i];
			if(n<=0)break;
		}
	}
	printf("%d\n",i);
	return 0;
}

#include <stdio.h>

int main(void)
{
  unsigned short page;
  scanf("%hu", &page);

  const unsigned short DAYS = 7;
  unsigned short pages[DAYS];
  for (unsigned short i = 0; i < DAYS; ++i)
    scanf("%hu", &pages[i]);

  unsigned short day = 1;
  unsigned short i = 0;
  while (page - pages[i] > 0)
  {
    page -= pages[i++];
    if (day++ == DAYS)
    {
      day = 1;
      i = 0;
    }
  }

  printf("%hu", day);

  return 0;
}

#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int main()
{
    int n,a[7],i,ans;
    scanf("%d",&n);
    for(i=0;i<7;i++)
    {
        scanf("%d",&a[i]);
    }
    while(n>0)
    {
        for(i=0;i<7;i++)
        {
            if(n>a[i])
                n=n-a[i];
            else
            {
                ans=i+1;
                n=0;
                break;
            }
        }
    }
    printf("%d",ans);
    printf("\n");
    return 0;
}

#include <stdio.h>

int main(int argc, char const *argv[]){

	int  n, j = 0;

	int leer[7];

	scanf("%d", &n);
	scanf("%d %d %d %d %d %d %d",&leer[0],&leer[1],&leer[2],&leer[3],&leer[4],&leer[5],&leer[6]);

	while(n > 0){
		n = n - leer[j];
		j++;
		j = j % 7;
	}
	if ( j == 0){
		j = 7;
	}
	printf("%d",j );
	return 0;
}

#include<stdio.h>
int main()
{
    int n, arr[7], i;
    scanf("%d", &n);
    for(i=0; i<7; i++)
    {
        scanf("%d", &arr[i]);
    }
    while(n>0)
    {
        for(i=0; i<7; i++)
        {
            n-=arr[i];
            if(n<=0)
            {
                printf("%d", i+1);
                return 0;
            }

        }
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define REP(i, a, b) for((i) = (a) ; i < (b) ; i++)

int n, arr[15];

int main() {
//	freopen("input.in", "r", stdin);
	int n, i;
	scanf("%d", &n);
	REP(i, 0, 7) scanf("%d", &arr[i]);
	int sum = 0;
	i = 0;
	while(1) {
		sum += arr[i];
		if(sum >= n) break;
		i++;
		i%=7;
	}
	printf("%d", i+1);
	return 0;
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a[7],i,sum=0,left=0;
    for(i=0;i<7;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    i=0;
    while(1)
    {
        if(a[i]>=n)
        {
            printf("%d",i+1);
            return 0;
        }
        else
            n-=a[i];
        if(i==6)
            i=0;
        else i++;
    }
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i;
    scanf("%d", &n);
    int a[n];
    for(i=1;i<=7;i++){
        scanf(" %d",&a[i]);
    }

    while(n>0){
        if(n<=a[1]){
            printf("1");
            break;
        }else{
            n-=a[1];
        }
        if(n<=a[2]){
            printf("2");
            break;
        }else{
            n-=a[2];
        }
        if(n<=a[3]){
            printf("3");
            break;
        }else{
            n-=a[3];
        }
        if(n<=a[4]){
            printf("4");
            break;
        }else{
            n-=a[4];
        }
        if(n<=a[5]){
            printf("5");
            break;
        }else{
            n-=a[5];
        }
        if(n<=a[6]){
            printf("6");
            break;
        }else{
            n-=a[6];
        }
        if(n<=a[7]){
            printf("7");
            break;
        }else{
            n-=a[7];
        }

    }
    return 0;
}

#include<stdio.h>
int main()
{
int n,i=0,a[7],sum=0;
scanf("%d",&n);
for(i=0;i<7;i++)
scanf("%d",&a[i]);
i=0;
while(sum<n)
{
sum=sum+a[i];
i++;
if(i>=7)
i=i-7;
}
if(i==0)
printf("7");
else
printf("%d",i);
return 0;
}

#include<stdio.h>
int main()
{
    int total, day;
    scanf("%d",&total);
    int a[8], i, read = 0;

    for(i = 1; i < 8; i++){
        scanf("%d",&a[i]);
    }

    for(i = 1; i < 8; i++){
        read += a[i];
        //printf("read: %d\n",read);
        if(read >= total){
            day = i;
            break;
        }
        if(i == 7){
            i = 0;
         }
        }

    printf("%d\n",day);

    return 0;
}

#include <stdio.h>
int main()
{
    int n, day[10], i;
    scanf(" %d", &n);
    for(i = 1; i <= 7; i++)
        {
            scanf(" %d", &day[i]);
        }
    while(1)
     {
        for(i = 1; i <= 7; i++)
        {
            n -= day[i];
            if(n <= 0) goto ans;
        }
    }
    ans:
    printf("%d", i);
    return 0;
}

#include<stdio.h>
int main()
{
    int n, pages[7];
    scanf("%d", &n);
    for(int i=0; i<7; i++){
        scanf("%d", &pages[i]);
    }
    int i=0, total=0, cnt = 1;
    while(i<7){
        total += pages[i];
        //cnt++;
        //i++;
        if(total >= n){
            break;
        }

        else if(i==6 && total<n){
            i=0;
            cnt = 1;
        }
        else if(cnt==7 && total<n){
            cnt = 1;
        }
        else{
            cnt++;
            i++;
        }

        //printf("%d %d\n", cnt, pages[i]);
    }
    printf("%d\n", cnt);
    return 0;
}

#include <stdio.h>
int main()
{
    int n, day[8], i;
    scanf(" %d", &n);
    for(i = 1; i <= 7; i++) scanf(" %d", &day[i]);
    while(1) {
        for(i = 1; i <= 7; i++) {
            n -= day[i];
            if(n <= 0) goto ans;
        }
    }
    ans:
    printf("%d", i);
    return 0;
}

#include<stdio.h>
int main() {
  int n;
  scanf("%d",&n);
  int read[7];
  int i;
  for(i=0;i<7;i++) {
    scanf("%d",&read[i]);
  }
  int sum=0;
  i=0;
  int res=0;
  while(1) {

    if(sum>=n) {
      res=i;
      break;
    }
    if(i==7) i=0;
    sum+=read[i];

    i++;
  }
  printf("%d\n",res);
  return 0;
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int sum=n;
    int i;

    int a[7];

    for(i=0;i<7;i++)
    {
       scanf("%d",&a[i]);
    }
    i=0;
    while(1)
    {
         sum=sum-a[i];
        if(sum<=0)
        {
            printf("%d",i+1);
            return 0;
        }
         if(i==6) i=-1;
        i++;

    }
}

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

#define lli long long int
#define MAX INT_MAX
#define PI acos(-1)
#define FOR(ii,aa,bb) for(ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(ii=aa;ii>bb;ii--)
#define buyuk(a,b) (a<b)? b:a
#define min(a,b) (a<b)? a:b
#define ort(a,b) (a+b)/2
#define carp(a,b) (a)*(b)
/*
   void sort(int bas,int ort,int son){
   int yer=bas,x=bas,y=ort+1,t,i;
   while(x <= ort && y <= son){
   if(a[x] < a[y]) temp[yer++]=a[x++];
   else temp[yer++]=a[y++];}
   while(x <= ort) temp[yer++]=a[x++];
   while(y <= son) temp[yer++]=a[y++];
   for(i=bas;i<=son;i++) a[i]=temp[i];}
   void merge(int bas,int son){
   if(son <= bas)return;
   int ort=(bas+son)/2;
   merge(bas,ort);
   merge(ort+1,son);
   sort(bas,ort,son);}
   */
int main () {
	int x,a[1005],i,j,top=0;
	scanf("%d",&x);
	for(i=0;i<7;i++)
		scanf("%d",&a[i]);
	for(j=1;j<=x;j++)
		for(i=0;i<7;i++){
			top+=a[i];
	if(top>=x){
		printf("%d",i+1);
	return 0;
	}
		}
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
      int n,p=0,i;
      int a[7];
     scanf("%d",&n);
     for(i=0;i<7;i++)
     {
         scanf("%d",&a[i]);
     }
     while(n>0)
     {
         n=n-a[p];
         if(n<=0)
            break;
         else
         {
             p++;
            p=p%7;
         }
     }
     printf("%d",p+1);
    return 0;
}

#include <stdio.h>

int main(void)
{
    int n, arr[7], i;

    scanf("%d", &n);

    for (i = 0; i < 7; i++) {
        scanf("%d", &arr[i]);
    }

    i = 0;
    while (n > 0) {
        n -= arr[i];
        i = (i + 1) % 7;
    }

    if (i == 0)
        printf("7\n");
    else
        printf("%d\n", i);

    return 0;
}

#include <stdio.h>
int main()
{
    int n,i,sum=0,j=1;
    scanf("%d",&n);
    int a[8];
    for(i=1;i<8;i++)
    scanf("%d",&a[i]);
    while(1)
    {

            sum=sum+a[j];
            if(sum>=n)
            {
                printf("%d",j);
                break;
            }
            j++;
            if(j>7)
                j=1;
    }
    return 0;
}

#include <stdio.h>

int main () {

	int p=0, i=0;
	int d[7];

	scanf("%d", &p);

	for (i=0; i<7; i++)
		scanf("%d", &d[i]);

	i=0;
	while (p > 0) {
		p -= d[i];
		i++;
		if (i>=7)
			i=0;
	}

	if (i==0)
		printf("7\n");
	else
		printf("%d\n", i);

	return 0;
}

#include<stdio.h>
int main()
{
    int n, i, a[8], c = 0, sum = 0;

    scanf("%d", &n);
    for(i=1; i<=7; i++)
        scanf("%d", &a[i]);

    while(1)
    {
        for(i=1 ;i<=7; i++)
        {
            sum = sum + a[i];
            if(sum >= n)
            {
                printf("%d\n", i);
                c = 1;
                break;
            }
        }
        if(c) break;
    }
    return 0;
}

#include <stdio.h>

int main(void){
    int pages, sum=0;
    int pagesbyday[7] = {0};
    scanf("%d", &pages);
    for(int i=0; i<7; ++i){
        scanf("%d", &pagesbyday[i]);
    }
    int i;
    for(i=0; sum<pages; ++i){
        sum+= pagesbyday[i%7];
    }
    int b= i%7;
    if(i%7 == 0) b = 7;
    printf("%d", b);
}

/*One Sunday Petr went to a bookshop and bought a new book on sports programming. The book had exactly n pages.

Petr decided to start reading it starting from the next day, that is, from Monday. Petr's got a very tight schedule and for each day of the week he knows how many pages he will be able to read on that day. Some days are so busy that Petr will have no time to read whatsoever. However, we know that he will be able to read at least one page a week.

Assuming that Petr will not skip days and will read as much as he can every day, determine on which day of the week he will read the last page of the book.

Input
The first input line contains the single integer n (1<=n<=1000) the number of pages in the book.

The second line contains seven non-negative space-separated integers that do not exceed 1000 �� those integers represent how many pages Petr can read on Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday correspondingly. It is guaranteed that at least one of those numbers is larger than zero.

Output
Print a single number �� the number of the day of the week, when Petr will finish reading the book. The days of the week are numbered starting with one in the natural order: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.

Examples
input
100
15 20 20 15 10 30 45
output
6
input
2
1 0 0 0 0 0 0
output
1*/
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int pagenum[7];
    for(int i=0;i<7;i++)
        scanf("%d",&pagenum[i]);
    int sum = 0,i;
    for(i=0;sum<n;i++)
    {
        i = i%7;
        sum += pagenum[i];
    }
    printf("%d",i);
}

#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,j,remainder,sum=0,loop,page[105];

    scanf("%d",&n);

    for(i=1;i<=7;i++)
    {
        scanf("%d",&page[i]);
    }

    loop:for(i=1;i<=7;i++)
        {

                    sum=sum+page[i];
                    if(sum>=n)
                    {
                        break;
                    }
        }
        if(sum<n)
        {
            goto loop;
        }

        printf("%d\n",i);

    return 0;
}

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,d,x,m,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,a[10000]={0},b;

scanf("%lld",&n);
  sum=0;
for(i=0;i<=6;i++){

    scanf("%lld",&a[i]);
    sum+=a[i];
}
n=n%sum;
if(n==0){
    n=sum;
}

i=0;
while(n>0){
    n-=a[i];
    i++;

}

printf("%lld",i);

return 0;
}

#include<stdio.h>
int main ()
{
	int arr[1010], i, n, page;
	scanf("%d",&n);
	for (i = 1; i<=7; i++)
	{
		scanf("%d", &arr[i]);
	}
	while(1)
    {
        for(i = 1; i<=7; i++)
        {
            n  =  n - arr[i];
            if(n<=0)
            {
                printf("%d\n",i);
                break;
            }
            if(i==7)
            {
                i=0;
                continue;
            }
            else continue;
        }
        if(n<=0)break;
    }
	return 0;

}

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
long long int max(long long int a,long long int b){
    if(a>b){
        return a;
    }
    return b;
}
long long int cmp(const void *a,const void *b){
    return *(long long int *)b-*(long long int*)a;
}
int main()
{
   long long int i,j,test,k,m,l,r,flag=0,max=0,n,m1,m2,x,sum=0,ans=0,count, a[10000]={0},b[1000]={0};
scanf("%lld",&n);
sum=0;
for(i=0;i<8;i++){
    scanf("%lld",&a[i]);
    sum+=a[i];
}
//printf("%lld\n",sum);
count=1;
i=0;
    while(n-a[i]>0 && i<7){
        count++;
     //  printf("%lld %lld\n",a[i],sum);
        n=n-a[i];
        i++;
        if(count==8){
            count=1;
        }
        if(i==7){
            i=0;
        }
    }

    printf("%lld",count);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n,i,a[1001];
    scanf("%d", &n);
    for(i=0;i<7;i++){
        scanf("%d", &a[i]);
    }
    i=0;
    while(n>0){
        n=n-a[i];
        i++;
        if(i==7&& n>0){
            i=0;
        }
    }
    printf("%d\n",i);
    return 0;
}

#include <stdio.h>

int main()
{
	int pages, i;
	int A[10];
	scanf("%d", &pages);

	for (i = 1; i <= 7; i++)
		scanf("%d", &A[i]);
	A[0] = A[7];
	for (i = 1;; i++)
	{
		pages -= A[i % 7];
		if (pages <= 0)
			break;
	}

	i %= 7;
	if (!i)
		i = 7;
	printf("%d", i);
	return 0;
}

#include <stdio.h>

int arr[7];

int main()
{
    int n, i, sum = 0, count = 0;
    scanf("%d", &n);

    for(i=0; i<7; i++){
        scanf("%d", &arr[i]);
        sum = sum + arr[i];
    }

    while(1){
        for(i=0; i<7; i++){
            count = count + arr[i];
            if(count >= n){
                printf("%d", i + 1);
                return 0;
            }
        }
    }
}

#include<stdio.h>
int main()
{
    int n,i,s=0
    ;
    int a[1005];
  scanf("%d",&n);
    for(i=1;i<=7;i++)
    {
        scanf("%d",&a[i]);
    }

        for(i=1;i<=7;i++)
        {
            s=s+a[i];
            if(s>=n)
            {
                printf("%d",i);
                break;
            }
            else if(i==7 && s<n)
            {
                i=i-7;
                continue;
            }
            else
                continue;
        }
    return 0;
}

#include<stdio.h>
int main()
{
    int n,i,s=0
    ;
    int a[1005];
  scanf("%d",&n);
    for(i=1;i<=7;i++)
    {
        scanf("%d",&a[i]);
    }
    i=0;
    while(1)
    {
     s=s+a[i];
     if(s>=n)
     break;
     i=i%7;
      i++;
    }
    printf("%d",i);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
	int n,d;
	int a[7];
	d=-1;
	scanf("%d",&n);
	for (int i = 0; i < 7; ++i)
	{
		scanf("%d",&a[i]);
	}
	while(n>0)
	{
		d=(d+1)%7;
		n=n-a[d];
	}
	printf("%d",d+1);
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a[7];
    int i;
    for (i=0;i<7;i++){
        scanf("%d",&a[i]);
    }
    i=0;
    while (n>0){
        n=n-a[i];
        i++;
        if (i>6){
            i=0;
        }
    }
    if (i==0){
        printf("%d",7);
    }else
    printf("%d",i);
    return 0;
}

#include<stdio.h>
int s(int x[], int y);
int sum=0;
int main()
{
int  n, i, day[1000], z;
scanf("%d", &n);
for(i=1; i<=7;i++)
    scanf("%d", &day[i]);
z= s(day, n);
printf("%d\n", z);

return 0;
}

int s(int x[], int y)
{
int i, n=y;
for(i=1; i<=7;i++)
{
    sum+= x[i];
    if(sum>=n)
    return(i);
}
if(i==8)
 s(x, n);
}

#include <stdio.h>
int main()
{
    int sum,i,d[7];
    scanf("%d", &sum);
    for(i=1;i<=7;i++)
    {
        scanf("%d", &d[i]);
    }
    for(i=1;i<=7;i++)
    {
        if(sum<=d[i])
        {
            printf("%d", i);
            break;
        }
        sum=sum-d[i];
        if(i==7)
        {
            i=0;
        }
    }
    return 0;
}

//In the name of God

#include <stdio.h>

int main()
{
	int b;
	scanf("%d",&b);
	int a[10],i,n=7;
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int c=b,cn=0;
	for(i=1;c>0;i++)
	{
		if(i==8)
			i=1;
		c=c-a[i];
		cn++;
	}
	//printf("%d\n",cn);
	if(cn%7==0)
		printf("7\n");
	else
		printf("%d\n",(cn%7));
	return 0;
}

#include<stdio.h>
int main()
{
    long long int n,a[8],i,s=0,q,k,d=0;
    scanf("%lld",&n);
    for(i=1;i<=7;i++)
    {scanf("%lld",&a[i]);
     s=s+a[i];
    }
    k=s;
    if(s>n)
    {s=0;
     i=0;
     while(s<n)
     {i++;
      s=s+a[i];
     }
     printf("%lld",i);
    }
    else
    {n=n%s;
     s=0;
     i=0;
     while(s<n&&n!=0)
     {i++;
      s=s+a[i];
     }
     if(n!=0)
    {
     printf("%lld",i);

    }
    else
    {for(i=1;i<=7;i++)
     {d=d+a[i];
      if(d==k)
      {printf("%lld",i);
       break;
      }
     }
    }
  }
    return 0;
}

#include<stdio.h>
int main()
{
     int n,i;
     scanf("%d",&n);
     int a[7];
     for(i=0;i<7;i++)
     {
          scanf("%d",&a[i]);
     }
     int sum=0,s,p=0;
     while(1)
     {
           for(i=0;i<7;i++)
           {
                sum=sum+a[i];
          if(sum>=n)
          {
               s=i+1;
               p=1;
               break;
          }
           }
           if(p==1)
           {
                break;
           }
     }
     if(s<=7)
     {
          printf("%d\n",s);
     }
     else
     {
          printf("%d\n",s%7);
     }
     return 0;
}

#include <stdio.h>
int main()
{
    int i, x, a[7], y = 0, count = 0;
    scanf("%d", &x);
    for(i = 0; i<7; i++) {
        scanf("%d", &a[i]);
    }
    while(y < x) {
        y = y + a[count];
        count++;
        if(count>6)
            count = 0;
    }
    if(count%7 == 0) {
        y = 7;
    }
    else {
        y = count%7;
    }
    printf("%d", y);
}

#include<stdio.h>
int main ()
{
    int n,i,j,count=0;
    scanf("%d",&n);
    int array[7];
    for(i=0;i<7;i++)

    {
        scanf("%d",&array[i]);
    }
    for(i=0;;i++){

        count=count+array[i];

        if(count>=n)
        {
            i++;

            break;
        }

    }

   if(i<7)
    printf("%d",i);
   else
    printf("%d",(i%7));

}

#include <stdio.h>
int main()
{
	int n, i;
	int days[7];
	scanf("%d", &n);
	for(i=0; i<7; i++)
	{
		scanf("%d", &days[i]);
		n-=days[i];
		if(n<=0)
			break;
	}
	while(n>0)
	{
		if(i<7)
                        i++;
                else
                        i = 0;
		n-=days[i];
	}
	//printf("%d\n", (n==0) ? i : i+1);
	printf("%d\n", i+1);
	return 0;
}

#include<stdio.h>
int main()
{
    int i, p, k, arr[7], brr[7];
    scanf("%d",  &p);
    for(i=0; i<7; i++)
    {
        scanf("%d", &arr[i]);
    }
    brr[0]=arr[0];
    for(i=1; i<7; i++)
    {
        brr[i]=brr[i-1]+arr[i];
    }
   /*for(i=0; i<7; i++)
    {
        printf("%d ", brr[i]);
    }*/
    //k=p-brr[6];
    int flag;
    if(p>brr[6])
    {
        //printf("aaaaaa\n");
       p=p%brr[6];
        if(brr[0]>=p)
        {
            printf("1");
            return 0;
        }

        for(i=0; i<7; i++)
        {
            if(brr[i]<p && brr[i+1]>p)
            {
                flag=0;
                break;
            }
            else if(brr[i]==p)
            {
                flag=1;
                break;
            }
        }
    }
    else
    {
       // printf("bbbbb\n");
        if(brr[0]>=p)
        {
            printf("1");
            return 0;
        }
         for(i=0; i<7; i++)
         {
             if(brr[i]<p && brr[i+1]>p)
             {
                flag=0;
                //printf("%d    ", i);
                break;
             }
             else if(brr[i]==p)
             {
                 flag=1;
                 break;
             }
         }
    }

    if(flag==0)
        printf("%d", (i+2));
    else
        printf("%d", i+1);
    return 0;
}

#include<stdio.h>
int main()
{
    int n,w[100],i,sum=0,j=0;
    scanf("%d",&n);
    for(i=1;i<=7;i++)  scanf("%d",&w[i]);
        while(sum<n || sum==n){
                if (j>7) j=0;
                j++;
                    sum=sum+w[j];
                printf("%d\n",sum);
                }
        printf("%d",j);
    return 0;
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int sum=n;
    int i;

    int a[7];

    for(i=0;i<7;i++)
    {
       scanf("%d",&a[i]);
    }
    i=0;
    while(1)
    {
         sum=sum-a[i];
        if(sum<=0)
        {
            printf("%d",i+1);
            return 0;
        }
        i++;
        if(i==6) i=0;

    }
}

#include<stdio.h>
int s(int x[], int y);
int sum=0;
int main()
{
int  n, i, day[1000], z;
scanf("%d", &n);
for(i=1; i<=n;i++)
    scanf("%d", &day[i]);
z= s(day, n);
printf("%d\n", z);

return 0;
}

int s(int x[], int y)
{
int i, n=y;
for(i=1; i<=n;i++)
{
    sum+= x[i];
    if(sum>=n)
    return(i);
}
if(i=(n+1) && sum< n)
 s(x, n);
}

#include<stdio.h>
int main()
{
int n,i=0,a[7],sum=0;
scanf("%d",&n);
for(i=0;i<7;i++)
scanf("%d",&a[i]);
i=0;
while(sum<n)
{
sum=sum+a[i];
i++;
if(i>=7)
i=i-7;
}
printf("%d",i);
return 0;
}

#include<stdio.h>
int main()
{
    long a[7],m,sum=0,count=0,i;
    scanf("%ld",&m);
    for(i=0;i<7;i++)
    scanf("%ld",&a[i]);
    for(;;){
        for(i=0;i<7;i++)
        {
            sum+=a[i];
            if(sum<=m)
                count++;
            else
                break;

        }if(sum>m)
        {printf("%ld",count+1);
        break;}
        else
            {m=m-sum;
            sum=0;
            count=0;}

    }
}

#include <stdio.h>
int main()
{
    int i, x, a[7], y = 0, count = 0;
    scanf("%d", &x);
    for(i = 0; i<7; i++) {
        scanf("%d", &a[i]);
    }
    while(y < x) {
        y = y + a[count];
        count++;
    }
    if(count%7 == 0) {
        y = 7;
    }
    else {
        y = count%7;
    }
    printf("%d", y);
}

#include<stdio.h>
#include<string.h>
int main()
{
    int n,i=0;
    scanf("%d",&n);
    int a[7],s=0;
    for(int i=0;i<7;i++)
    {
        scanf("%d",&a[i]);
    }
    while(i>=0)
    {
        s+=a[i];
        if(s>=n && i<7)
        {
            printf("%d",i+1);
            break;
        }
        else if(s>=n && i>=7)
        {
            printf("%d",((i%7)+1));
            break;
        }
        i++;
    }
    return 0;
}

//In the name of God

#include <stdio.h>

int main()
{
	int b;
	scanf("%d",&b);
	int a[10],i,n=7;
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int c=b,cn=0;
	for(i=1;c>0;i++)
	{
		if(i==8)
			i=1;
		c=c-a[i];
		cn++;
	}
	if(cn%8==7)
		printf("7\n");
	else
		printf("%d\n",(cn%7));
	return 0;
}

#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int days[7], j, sum = 0;
	for (j = 0; j < 7; j++)
	{
		scanf("%d", &days[j]);
		sum += days[j];
	}
	n %= sum;
	if (!n)
	{
		printf("7");
		return 0;
	}
	for (j = 0; j < 7; j++)
	{
		if (!days[j])
			continue;
		if (n > 0)
			n -= days[j];
		if (n <= 0)
			break;
	}
	printf("%d\n", j + 1);
}

#include<stdio.h>
#include<math.h>
int main()
{  int n,i,s=0;
   scanf("%d",&n);
   int a[7];
   for(i=0;i<7;i++)
   {
       scanf("%d",&a[i]);
   }
   for(i=0;i<7;i++)
   {
       s=s+a[i];
       if(s>n)
       {
           printf("%d",i+1);
           return 0;
       }
   }

   if(s<n)
   {
    for(i=6;i>=0;i--)
    {
        if(a[i]==0)
        {
            continue;
        }
        else
        {
            printf("%d",i+1);
            return 0;
        }
    }
   }
return 0;
  }

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i, page, day=0, count=0;
    int arr[7];
    scanf("%d", &page);
    for(i=0; i<7; i++)scanf("%d", &arr[i]);
    i=0;
    while(count<page){
        count+=arr[i];
        day++;
        i++;
        if(i==7) i=0;
        printf("%d ", day);
    }
    if(day>7){
        if(day/8 == 7) day--;
        day%=8;
        day++;
    }
    printf("%d\n", day);
    return 0;
}

#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int days[7], j, sum = 0;
	for (j = 0; j < 7; j++)
	{
		scanf("%d", &days[j]);
		sum += days[j];
	}
	n %= sum;
	for (j = 0; j < 7; j++)
	{
		if (!days[j])
			continue;
		if (n > 0)
			n -= days[j];
		if(n <= 0)
			break;
	}
	printf("%d\n", j + 1);
}

#include <stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
long long cmpfunc (const void * a, const void * b) {
   return ( *(long long*)a - *(long long*)b );
}

int main(void){

long long int test,i,j,n,count,flag=0,o1=0,o2=0,b1,d,x,m,l,max,sum2,min,f,c,r,o,sum1,sum=0,y,a[10000]={0},b;

scanf("%lld",&n);
  sum=0;
for(i=0;i<=6;i++){

    scanf("%lld",&a[i]);
    sum+=a[i];
}
if(sum>1){
n=n%sum;
}
i=0;
while(n>0){
    n-=a[i];
    i++;
  //  printf("%lld ",n);
  if(i==7){
      i=0;
  }
}
printf("%lld",i);

return 0;
}

#include <stdio.h>
#include <stdlib.h>
//#include <math.h>
int main()
{
  int n,s=0,i,f=0,ans=0;
  int a[8];
  scanf("%d",&n);
  for(i=0;i<7;i++)
  {
      scanf("%d",&a[i]);
      s=s+a[i];
     // printf("s=%d\n",s);
      if(s>=n && f==0)
      {
          f=1;
          ans=i;
      }
  }
  i=ans;
  if(ans==0)
  {

  n=n%s;
  s=0;
  for(i=0;i<7;i++)
  {
      s=s+a[i];
      if(s>=n)
        break;
  }
  }
    printf("%d",i+1);
    return 0;
}

#include<stdio.h>

int main()
{
	int n, a[7], i, j, s=0;
	scanf("%d", &n);
	for(i=0; i<7; i++)
	{
		scanf("%d", &a[i]);
		s = s + a[i];
	}
	j = n%s;
	for(i=0; i<7; i++)
	{
		if(j==0)
		{
			j=n;
			if(j<=a[i])
		    { printf("%d", i+1);
			  break;
		    }
		    else
		    j = j - a[i];
		}
		else
		{
			if(j<=a[i])
		{
			printf("%d", i+1);
			break;
		}
		else
		j = j - a[i];
		}
	}
	return 0;
}

#include <stdio.h>
int main()
{
    int n, i;
    scanf("%d", &n);
    int arr[7];
    for(i=0; i<7 ; i++)
    {
        scanf("%d", &arr[i]);
    }
    int total = 0;
    i=0;
    while(total < n)
    {
        total += arr[i];
        if(i==6) i=0;
        else ++i;
    }

    printf("%d\n", i);

    return 0;
}

#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    int myarray[7];
    int total=0,flag=0;
    for(i=0; i<7; i++)
    {
        scanf("%d",&myarray[i]);
    }
    for(i=0; i<7; i++)
    {
        total+=myarray[i];
        flag++;
        if(flag==7)
        {
            flag=0;
        }
        if(total>=n) break;

    }
    printf("%d",flag);
    return 0;

}

#include<stdio.h>
int main()
{
    int n, i;
    scanf("%d", &n);
    int a[7];
    for(i=0; i<7; i++)
    {
        scanf("%d", &a[i]);
    }
    for(i=0; 1 ;i++)
    {
        if(i==7)
        i=0;
        if(n<=0)
        {
            if(i==0)
            printf("1");
            else
            printf("%d", i);
            break;
        }
        n=n-a[i];
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    int arr[7];
    int i;
    for(i=0;i<7;i++){
        scanf("%d",&arr[i]);
    }
    i=0;
    while (n>0){
        n-=arr[i];
        i++;
        if(i==7)
            i=0;
    }
    printf("%d",i);
    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a[7];
    int i;
    for (i=0;i<7;i++){
        scanf("%d",&a[i]);
    }
    i=0;
    while (n>0){
        n=n-a[i%7];
        i++;
    }
    printf("%d",i%7);
    return 0;
}

#include<stdio.h>
int main(){
    int totpag=0,lu=0,ma=0,mi=0,ju=0,vi=0,sa=0,dom=0,dia=1;
    scanf("%d",&totpag);
    scanf("%d%d%d%d%d%d%d",&lu,&ma,&mi,&ju,&vi,&sa,&dom);
    do{
        if((dia%7)+1==1) totpag=totpag-lu;
        else if((dia%7)+1==2) totpag=totpag-ma;
        else if((dia%7)+1==3) totpag=totpag-mi;
        else if((dia%7)+1==4) totpag=totpag-ju;
        else if((dia%7)+1==5) totpag=totpag-vi;
        else if((dia%7)+1==6) totpag=totpag-sa;
        else if((dia%7)+1==7) totpag=totpag-dom;
        dia++;
        if (dia==8){ dia=1;}
    }while(totpag>1);
    if(totpag<=0){
    dia--;}
    printf("%d",dia);
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int n;
    scanf("%d",&n);
    int day[7];
    int i;
    int sum=0;
    int flag=0;
    int c=0;
    int sve;
    for(i=0;i<7;i++){
        scanf("%d",&day[i]);
        sum=sum+day[i];
        if(flag==0 && sum>=n){
            flag=1;
            sve=i;
        }
        if(day[i]==0){
            c=c+1;
        }
    }
    if(flag==1){
        printf("%d",sve+1);
    }
    if(flag==0){
        printf("%d",7-c);
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int i, p, k, arr[7], brr[7];
    scanf("%d",  &p);
    for(i=0; i<7; i++)
    {
        scanf("%d", &arr[i]);
    }
    brr[0]=arr[0];
    for(i=1; i<7; i++)
    {
        brr[i]=brr[i-1]+arr[i];
    }
   /*for(i=0; i<7; i++)
    {
        printf("%d ", brr[i]);
    }*/
    //k=p-brr[6];
    int flag;
    if(p>brr[6])
    {
        //printf("aaaaaa\n");
        while(p>brr[6])
        {
            p-=brr[6];
        }
        if(brr[0]>=p)
        {
            printf("1");
            return 0;
        }

        for(i=0; i<7; i++)
        {
            if(brr[i]<p && brr[i+1]>p)
                flag=0;
            else if(brr[i]==p)
            {
                flag=1;
                break;
            }
        }
    }
    else
    {
       // printf("bbbbb\n");
        if(brr[0]>=p)
        {
            printf("1");
            return 0;
        }
         for(i=0; i<7; i++)
         {
             if(brr[i]<p && brr[i+1]>p)
             {
                flag=0;
                //printf("%d    ", i);
                break;
             }
             else if(brr[i]==p)
             {
                 flag=1;
                 break;
             }
         }
    }

    if(flag==0)
        printf("%d", (i+2));
    else
        printf("%d", i+1);
    return 0;
}

#include<stdio.h>
int main()
{
    int i, p, k, arr[7], brr, sum=0, f=0;
    scanf("%d",  &p);
    for(i=0; i<7; i++)
    {
        scanf("%d", &arr[i]);
        sum+=arr[i];
    }

    if(p<=sum)
    {
        for(i=0; i<7; i++)
        {
            f+=arr[i];
            if(f>=p)
                break;
        }
    }
    else
    {
        k=p%sum;
    for(i=0; i<7; i++)
    {
        f+=arr[i];
        if(f>=k)
            break;
    }
    }
    printf("%d", i+1);
    return 0;
}

#include<stdio.h>
int main(){
	int n;
	int a[8];
	scanf("%d",&n);
	int i,sum=0,ans=0;
	for(i=0;i<7;i++){
		scanf("%d",&a[i+1]);
		sum=sum+a[i+1];
	}
//	printf("sum=%d\n",sum);
	while(1){
		if(n>sum)
			n=n-sum;
		else if(n==sum){
			ans=1;
			break;
		}
		else {
			for(i=1;i<=7;i++){
				n=n-a[i];
//				printf("n=%d\n",n);
				if(n<=0){
					ans=i;
					break;
				}
			}
		}
		if(ans!=0)
			break;
	}
	printf("%d\n",ans);
	return 0;
}

#include "stdio.h"

int main() {
  int n, arr[7], sum = 0, remain = 0, day, temp = 0;
  scanf("%d", &n);

  for (int i = 0; i < 7; i++) {
    scanf("%d", &arr[i]);
    sum += arr[i];
  }

  remain = n - sum * (n / sum);

  for (int i = 0; i < 7; i++) {
    temp += arr[i];
    if (temp >= remain) {
      day = i + 1;
      break;
    }
  }

  printf("%d\n", day);
  return 0;
}

/*

50
1 2 3 4 3 2 3 = 18
50/18 = 2
50-18(50/18)

*/

#include<stdio.h>
int main()
{
   int week,cnt;
   int i,n;
   int a[8];
   scanf("%d",&n);
   week=0;
   for(cnt=1;cnt<=7;cnt++)
      scanf("%d",&a[cnt]);

   i=1;
   while(n>=0){
      if(i==8) i=1;
      n-=a[i];
      i++;
   }
   printf("%d\n",i-1);
   return 0;
}

#include<stdio.h>

int main()
{
    int n, mon, tue, wed, thur, fri, sat, sun, sum=0, count=0, i;
    scanf("%d %d %d %d %d %d %d %d", &n, &mon, &tue, &wed, &thur, &fri, &sat, &sun);

    for(i=0; 1; i++)
    {
        sum = sum+mon;
    count++;
    if(sum>=n && i==0)
        {
            printf("1");
            break;
        }
    else if(sum>=n)break;
    else
    {
        sum = sum+tue;
        count++;
        if(sum>=n && i==0)
        {
            printf("2");
            break;
        }
        else if(sum>=n)break;
        else
        {
            sum = sum+wed;
            count++;
            if(sum>=n && i==0)
                {
            printf("3");
            break;
        }

            else if(sum>=n)break;
            else
            {
                sum = sum+thur;
                count++;
                if(sum>=n && i==0)
                    {
            printf("4");
            break;
        }
                else if(sum>=n)break;
                else
                {
                    sum = sum+fri;
                    count++;
                    if(sum>=n && i==0)
                        {
            printf("5");
            break;
        }
                    else if(sum>=n)break;
                    else
                    {
                        sum = sum+sat;
                        count++;
                        if(sum>=n && i==0)
                            {
            printf("6");
            break;
        }
                        else if(sum>=n)break;
                        else
                        {
                            sum = sum+sun;
                            count++;
                            if(sum>=n && i==0)
                                {
            printf("7");
            break;
        }
                            else if(sum>=n)break;
                        }
                    }
                }
            }
        }
    }
    }
    if(i!=0 && count%7 !=0)printf("%d", count%7);
    else printf("7");
}

#include <stdio.h>
int main()
{
	int n,i,sum=0,j=1;
	scanf("%d",&n);
	int a[n+1];
	for(i=1;i<n+1;i++)
	scanf("%d",&a[i]);
	while(1)
	{

			sum=sum+a[j];
			if(sum>=n)
			{
				printf("%d",j);
				break;
			}
			j++;
			if(j>n)
				j=1;
	}
	return 0;
}

#include<stdio.h>

int main()
{
    int n,sum=0,p=0;
    scanf("%d",&n);
    int ar[7];
    for(int i=0;i<7;i++)
    {
    scanf("%d",&ar[i]);
    sum+=ar[i];
    }
    if(n>sum)
    {
    n-=(n/sum)*sum;
    for(int i=0;i<7;i++)
    {
    if(ar[i]>=n&&ar[i]!=0)
    {
    p=i;
    break;
    }
    else
    n-=ar[i];
    }
    printf("%d",p+1);
    }
    else
    {
    for(int i=0;i<7;i++)
    {
    if(ar[i]>=n)
    {
    p=i;
    break;
    }
    else
    n-=ar[i];
    }
    printf("%d",p+1);

    }
    return 0;
}

#include<stdio.h>
int main()
{
    int n,i,sum=0,l=0,x,y,z;
    int p[8];
    scanf("%d",&n);
    for(i=1;i<=7;i++)
    {
        scanf("%d",&p[i]);
        sum=p[i]+sum;

    }
    x=n/sum;
    y=x*sum;
    z=n-y;
    for(i=1;i<=7;i++)
    {
        l=p[i]+l;
        if(l>=z)
        {
            break;
        }
    }
    printf("%d\n",i);
    return 0;
}

#include<stdio.h>

int main()
{
    int n, mon, tue, wed, thur, fri, sat, sun, sum=0, count=0, i;
    scanf("%d %d %d %d %d %d %d %d", &n, &mon, &tue, &wed, &thur, &fri, &sat, &sun);

    if(mon==0)mon = 1;
    if(tue==0)tue = 1;
    if(wed==0)wed = 1;
    if(thur==0)thur = 1;
    if(fri==0)fri = 1;
    if(sat==0)sat = 1;
    if(sun==0)sun = 1;

    for(i=0; 1; i++)
    {
        sum = sum + mon;
        if(sum>=n)break;
        count++;
    }
    printf("%d", count);

}

// C program for insertion sort
#include <stdio.h>
#include <math.h>
#include<string.h>
#include<stdlib.h>
int maxi(int n,int m)
{
    return n>m?n:m;
}
void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;

    /* create temp arrays */
    int L[n1], R[n2];

    /* Copy data to temp arrays L[] and R[] */
    for(i = 0; i < n1; i++)
        L[i] = arr[l + i];
    for(j = 0; j < n2; j++)
        R[j] = arr[m + 1+ j];

    /* Merge the temp arrays back into arr[l..r]*/
    i = 0;
    j = 0;
    k = l;
    while (i < n1 && j < n2)
    {
        if (L[i] <= R[j])
        {
            arr[k] = L[i];
            i++;
        }
        else
        {
            arr[k] = R[j];
            j++;
        }
        k++;
    }

    /* Copy the remaining elements of L[], if there are any */
    while (i < n1)
    {
        arr[k] = L[i];
        i++;
        k++;
    }

    /* Copy the remaining elements of R[], if there are any */
    while (j < n2)
    {
        arr[k] = R[j];
        j++;
        k++;
    }
}

/* l is for left index and r is right index of the sub-array
  of arr to be sorted */
void mergeSort(int arr[], int l, int r)
{
    if (l < r)
    {
        int m = l+(r-l)/2; //Same as (l+r)/2, but avoids overflow for large l and h
        mergeSort(arr, l, m);
        mergeSort(arr, m+1, r);
        merge(arr, l, m, r);
    }
}

int main()
 {
     int i=0,j=0,n,m,x,y,z,r,sum=0,arr[8],x1,x2,y1,y2;
    scanf("%d",&n);
    for(i=0;i<7;i++)
    {
        scanf("%d",&arr[i]);
        sum+=arr[i];
    }
    n=n%sum;
    if(n==0)
        printf("%d",i);
    else
    {i=0;
    for(i=0;i<7;i++)
    {
        n=n-arr[i];
        if(n<=0)
            break;
    }

    printf("%d",i+1);
     }        return 0;
 }

#include <stdio.h>

int arr[7];

int main()
{
    int n, i, sum = 0, count = 0;
    scanf("%d", &n);

    for(i=0; i<7; i++){
        scanf("%d", &arr[i]);
        sum = sum + arr[i];
    }

    n = n % sum;
    for(i=0; i<7; i++){
        count = count + arr[i];
        if(count >= n){
            printf("%d", i + 1);
            return 0;
        }
    }
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i, page, day=0, count=0;
    int arr[7];
    scanf("%d", &page);
    for(i=0; i<7; i++)scanf("%d", &arr[i]);
    i=0;
    while(count<page){
        count+=arr[i];
        day++;
        i++;
        if(i==7) i=0;
    }
    if(day>7){
        if(day/8 == 7) day--;
        day%=8;
        day++;
    }
    printf("%d\n", day);
    return 0;
}

#include<stdio.h>
int main ()
{
	int arr[1010], i, n, page;
	scanf("%d",&n);
	for (i = 1; i<=7; i++)
	{
		scanf("%d", &arr[i]);
	}
	for (i = 1; ; i++)
	{
	    n = n - arr[i];
		if (n<=0)
		{
			printf("%d\n", i);
			break;
		}
		else continue;
	}
	return 0;

}

#include <stdio.h>
#include <string.h>

int main() {

    int n, a[10], sum, left;
    int i, j;

    scanf("%d", &n);

    for (i = 0; i < 7; i++)
    {
    	scanf("%d", &a[i]);
    	sum += a[i];
	}

	if (sum > n)
	{
		left = n % sum;
	}
	else
	{
		left = n;
	}

	i = 0;
	j = 0;
	while (j < left)
	{
		if (i == 8)
		{
			i = 0;
		}

		j += a[i];
		i += 1;
	}

    printf("%d\n", i);

    return 0;

}

#include<stdio.h>
int main()
{
   int week,cnt;
   int i,n;
   int a[8];
   scanf("%d",&n);
   week=0;
   for(cnt=1;cnt<=7;cnt++){
      scanf("%d",&a[cnt]);
      week+=a[cnt];
   }
   if(n>week)
      n=n%week;

   for(i=1;i<=7;i++){
      n-=a[i];
      if(n<=0){
         printf("%d\n",i);
         break;
      }
   }
   return 0;
}

#include<stdio.h>
int main ()
{
    int n,i,count=0,flag=0;
    scanf("%d",&n);
    int array[7];
    for(i=0;i<7;i++)
    {
        scanf("%d",&array[i]);
    }
    for(i=0;i<7;i++)
    {
        count+=array[i];
        flag++;
        if(count>=n)
            break;
        if(flag==7)
        {
            flag=0;
            i--;
        }
    }
    printf("%d",flag);
}

#include<stdio.h>

int main()
{
    int n, mon, tue, wed, thur, fri, sat, sun, sum=0, count=0, i;
    scanf("%d %d %d %d %d %d %d %d", &n, &mon, &tue, &wed, &thur, &fri, &sat, &sun);

    for(i=0; 1; i++)
    {
        sum = sum+mon;
    count++;
    if(sum>=n && i==0)
        {
            printf("1");
            break;
        }
    else if(sum>=n)break;
    else
    {
        sum = sum+tue;
        count++;
        if(sum>=n && i==0)
        {
            printf("2");
            break;
        }
        else if(sum>=n)break;
        else
        {
            sum = sum+wed;
            count++;
            if(sum>=n && i==0)
                {
            printf("3");
            break;
        }

            else if(sum>=n)break;
            else
            {
                sum = sum+thur;
                count++;
                if(sum>=n && i==0)
                    {
            printf("4");
            break;
        }
                else if(sum>=n)break;
                else
                {
                    sum = sum+fri;
                    count++;
                    if(sum>=n && i==0)
                        {
            printf("5");
            break;
        }
                    else if(sum>=n)break;
                    else
                    {
                        sum = sum+sat;
                        count++;
                        if(sum>=n && i==0)
                            {
            printf("6");
            break;
        }
                        else if(sum>=n)break;
                        else
                        {
                            sum = sum+sun;
                            count++;
                            if(sum>=n && i==0)
                                {
            printf("7");
            break;
        }
                            else if(sum>=n)break;
                        }
                    }
                }
            }
        }
    }
    }
    if(i!=0 && count%7 !=0)printf("%d", count%7);
    else if(count%7 == 0) printf("7");
}

#include<stdio.h>
int main()
{
    int n,week[7],i,j=0;
    scanf("%d",&n);
    for(i=0;i<7;i++)
        scanf("%d",&week[i]);
    while(n>0)
    {
        n=n-week[j];
        j++;
        if(j>6) j=0;
    }
    printf("%d",j);
    return 0;
}

#include<stdio.h>
int main()
{
    int a[8];
    int i,count,n,b;
    while(scanf("%d",&n)==1)
    {
        b=0;
    for(i=0;i<7;i++)
    {
        scanf("%d",&a[i]);
    }
    i=0;
    while(b<n)
    {
        b=b+a[i%n];
        i++;

    }
    printf("%d\n",i%n);
    }
    return 0;
}

#include<stdio.h>
int main()
{
    int a[7],n,i;
    scanf("%d",&n);
    for(i=0;i<7;i++)
        scanf("%d",&a[i]);
    while(n>=0)
    {
        for(i=0;i<n;i++)
        {
            if(n>=0)
                n=n-a[i];
            else
                break;
        }
    }
    printf("%d",i+1);
    return 0;

}

#include <stdio.h>

int main(void) {
    int n,a[7],i,s;
    scanf("%d",&n);
    for(i=0;i<7;i++)
    scanf("%d",&a[i]);
    s=0;i=0;
    while(s<n)
     {
         s=s+a[i];
     if(i==6)
     i=0;
     else
     i++;

     }
     printf("%d",i);
    return 0;
}

#include<stdio.h>

int main(){
    int n=0,dni[7],i;
    scanf("%d",&n);
    for(i=0;i<7;i++)
        scanf("%d",&dni[i]);
    i=0;
    while(n>0){
        if(i==6) i=0;
        if(dni[i]!=0)
            n-=dni[i];
        i++;
    }
    printf("\n%d",i);
return 0;
}

#include"stdio.h"
int main()
{
    int n;
    scanf("%d",&n);
    int num[7];  // 0 is monday, 6 is sunday
    int i,s=0;
    for(i=0;i<7;i++){
        scanf("%d",&num[i]);
        s+=num[i];
    }
    int sum=n%s;
    int flag=0,j;

        for(j=0;j<7;j++)
        {
            sum-=num[j];
            if(sum<=0) { flag=j+1; break;}
        }

   printf("%d",flag);
   return 0;
}

#include<stdio.h>
int main()
{
    int n, i;
    scanf("%d", &n);
    int a[7];
    for(i=0; i<7; i++)
    {
        scanf("%d", &a[i]);
    }
    for(i=0; 1 ;i++)
    {
        if(i==7)
        i=0;
        if(n<=0)
        {
            if(i==0)
            printf("%d", i+1);
            else
            printf("%d", i);
            break;
        }
        n=n-a[i];
    }
    return 0;
}

#include<stdio.h>
int main(){
    int n,i,days,arr[7];
    scanf("%d",&n);
    for(i=0;i<7;i++){
        scanf("%d",&arr[i]);

    }
    i=-1;
    while(n>0){
        i++;
        n-=arr[i];

        if(n<=0){
            break;
        }

    }
    days=i%7;
    printf("%d",days+1);
    return 0;
}

#include"stdio.h"
int main()
{
    int n;
    scanf("%d",&n);
    int num[7];  // 0 is monday, 6 is sunday
    int i;
    for(i=0;i<7;i++)
    scanf("%d",&num[i]);
    int sum=n,flag=0,j;
    while(flag==0)
    {
        for(j=0;j<7;j++)
        {
            sum-=num[j];
            if(sum<0) { flag=j+1; break;}
        }

    }
   printf("%d",flag);
   return 0;
}

#include<stdio.h>
int main()
{
	int n,i,k=0;
	 scanf("%d",&n);
	 int a[7];
	 for(i=0;i<7;i++)
	 scanf("%d",&a[i]);
	 while(n>0)
	 {
	 	n=n-a[k%7];
	 	k++;
	 }
	 printf("%d",k%7);
}

#include <stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int a[7];
    for (int i=0;i<7;i++)
    scanf("%d",&a[i]);
    int k=0;int i=0;
    while (k<n)
    {
        k+=a[i];
        i++;
        if (i==7)
        i=0;
    }
     printf("%d",i);
}

#include<stdio.h>

int main()
{
    int n, mon, tue, wed, thur, fri, sat, sun, sum=0, count=0, i;
    scanf("%d %d %d %d %d %d %d %d", &n, &mon, &tue, &wed, &thur, &fri, &sat, &sun);

    for(i=0; 1; i++)
    {
        sum = sum+mon;
    count++;
    if(sum>=n && i==0)
        {
            printf("1");
            break;
        }
    else if(sum>=n)break;
    else
    {
        sum = sum+tue;
        count++;
        if(sum>=n && i==0)
        {
            printf("2");
            break;
        }
        else if(sum>=n)break;
        else
        {
            sum = sum+wed;
            count++;
            if(sum>=n && i==0)
                {
            printf("3");
            break;
        }

            else if(sum>=n)break;
            else
            {
                sum = sum+thur;
                count++;
                if(sum>=n && i==0)
                    {
            printf("4");
            break;
        }
                else if(sum>=n)break;
                else
                {
                    sum = sum+fri;
                    count++;
                    if(sum>=n && i==0)
                        {
            printf("5");
            break;
        }
                    else if(sum>=n)break;
                    else
                    {
                        sum = sum+sat;
                        count++;
                        if(sum>=n && i==0)
                            {
            printf("6");
            break;
        }
                        else if(sum>=n)break;
                        else
                        {
                            sum = sum+sun;
                            count++;
                            if(sum>=n && i==0)
                                {
            printf("7");
            break;
        }
                            else if(sum>=n)break;
                        }
                    }
                }
            }
        }
    }
    }
    if(i!=0)printf("%d", count%7);
}

#include <stdio.h>
int main()
{
    int i, x, a[7], y = 0, count = 0;
    scanf("%d", &x);
    for(i = 0; i<7; i++) {
        scanf("%d", &a[i]);
    }
    while(y < x) {
        y = y + a[count];
        count++;
        if(count>7)
            count = 1;
    }
    if(count%7 == 0) {
        y = 7;
    }
    else {
        y = count%7;
    }
    printf("%d", y);
}

#include<stdio.h>
int main(){
int n,x[7],i,sum;
scanf("%d",&n);
for(i=0;i<7;i++)scanf("%d",&x[i]);
sum=n;
i=-1;
while(sum>=0){
    ++i;
    sum=sum-x[i];
    if(i==7)i=-1;
}
printf("%d",++i);

           return 0;}

#include <stdio.h>

int arr[7];

int main()
{
    int n, i, sum = 0, count = 0;
    scanf("%d", &n);

    for(i=0; i<7; i++){
        scanf("%d", &arr[i]);
        sum = sum + arr[i];
    }

    n = n % sum;
    for(i=0; i<7; i++){
        count = count + arr[i];
        if(count >= n){
            printf("%d", i + 1);
            return 0;
        }
    }
}

#include<stdio.h>
int main()
{
    int i, p, k, arr[7], brr[7];
    scanf("%d",  &p);
    for(i=0; i<7; i++)
    {
        scanf("%d", &arr[i]);
    }
    brr[0]=arr[0];
    for(i=1; i<7; i++)
    {
        brr[i]=brr[i-1]+arr[i];
    }
   /*for(i=0; i<7; i++)
    {
        printf("%d ", brr[i]);
    }*/
    //k=p-brr[6];
    int flag;
    if(p>brr[6])
    {
        //printf("aaaaaa\n");
       p=p%brr[6];
       if(p==0)
       {
           printf("7");
           return 0;
       }
        else if(brr[0]>=p)
        {
            printf("1");
            return 0;
        }

        for(i=0; i<7; i++)
        {
            if(brr[i]<p && brr[i+1]>p)
            {
                flag=0;
                break;
            }
            else if(brr[i]==p)
            {
                flag=1;
                break;
            }
        }
    }
    else
    {
       // printf("bbbbb\n");
        if(brr[0]>=p)
        {
            printf("1");
            return 0;
        }
         for(i=0; i<7; i++)
         {
             if(brr[i]<p && brr[i+1]>p)
             {
                flag=0;
                //printf("%d    ", i);
                break;
             }
             else if(brr[i]==p)
             {
                 flag=1;
                 break;
             }
         }
    }

    if(flag==0)
        printf("%d", (i+2));
    else
        printf("%d", i+1);
    return 0;
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int sum=n;
    int i;

    int a[7];

    for(i=0;i<7;i++)
    {
       scanf("%d",&a[i]);
    }
    i=0;
    while(1)
    {
         sum=sum-a[i];
        if(sum<=0)
        {
            printf("%d",i+1);
            return 0;
        }
        i++;
        if(i==6) i=0;

    }
}

#include <stdio.h>
int main()
{
	int n,i,sum=0,j=1;
	scanf("%d",&n);
	int a[n+1];
	for(i=1;i<n+1;i++)
	scanf("%d",&a[i]);
	while(1)
	{

			sum=sum+a[j];
			if(sum>=n)
			{
				printf("%d",j);
				break;
			}
			j++;
			if(j>7)
				j=1;
	}
	return 0;
}

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAX
int main()
{
   int week,cnt;
   int i,n;
   int a[8];
   scanf("%d",&n);
   week=0;
//   printf("\n%d\n",n);
   for(cnt=1;cnt<=7;cnt++){
         scanf("%d",&a[cnt]);
         week+=a[cnt];
   }
  // printf("\n%d\n",n);
   n=n%week;
 //  printf("%d\n",n);
   for(i=1;i<=7;i++){
      n-=a[i];
      if(n<=0){
         printf("%d\n",i);
         break;
      }
   }
   return 0;
}

#include<stdio.h>

int main()
{
    int n;
    scanf("%d",&n);
    int a[7],i,sum=0,left=0;
    for(i=0;i<7;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    if(n>=sum)
    {
        left=n-(n/sum)*sum;
    }
    else left=n;
    i=0;
    while(1)
    {
        if(a[i]>=left)
        {
            printf("%d",i+1);
            return 0;
        }
        else
        {
            left=left-a[i++];
        }
    }

    return 0;
}

#include<stdio.h>
int main()
{
    int n,i,count=1,a,k;
    scanf("%d",&n);
    int arr[7];
    for(i=1;i<=7;i++)
    {
        scanf("%d",&arr[i]);
    }
    for(i=1;i<=7;i++)
    {
        n=n-a;
        if(n>0)
        {
            count++;
            if(arr[i]==0)
            {
                break;
            }
        }
    }
    printf("%d",count);

    return 0;
}

#include<stdio.h>
int main()
{
    int i, p, k, arr[7], brr[7];
    scanf("%d",  &p);
    for(i=0; i<7; i++)
    {
        scanf("%d", &arr[i]);
    }
    brr[0]=arr[0];
    for(i=1; i<7; i++)
    {
        brr[i]=brr[i-1]+arr[i];
    }
   /*for(i=0; i<7; i++)
    {
        printf("%d ", brr[i]);
    }*/
    //k=p-brr[6];
    int flag;
    if(p>brr[6])
    {
        //printf("aaaaaa\n");
        while(p>brr[6])
        {
            p-=brr[6];
        }
        for(i=0; i<7; i++)
        {
            if(brr[i]<p && brr[i+1]>p)
                flag=0;
            else if(brr[i]==p)
            {
                flag=1;
                break;
            }
        }
    }
    else
    {
       // printf("bbbbb\n");
         for(i=0; i<7; i++)
         {
             if(brr[i]<p && brr[i+1]>p)
             {
                flag=0;
                //printf("%d    ", i);
                break;
             }
             else if(brr[i]==p)
             {
                 flag=1;
                 break;
             }
         }
    }

    if(flag==0)
        printf("%d", (i+2));
    else
        printf("%d", i+1);
    return 0;
}

#include<stdio.h>
int main(){
int n,x[7],i,sum;
scanf("%d",&n);
for(i=0;i<7;i++)scanf("%d",&x[i]);
sum=n;
i=-1;
while(sum>0){
    ++i;
    sum=sum-x[i];
}
printf("%d",++i);

           return 0;}

#include<stdio.h>
#include<stdlib.h>

int main(){
 int tab[7];
 int i,j,n,page;
 scanf("%d",&n);
 for(i=1;i<=7;i++)
    scanf("%d",&tab[i]);
 while(n>=0){
    for(i=1;i<=7;i++){
        n-=tab[i];
        if(n<=0){
            printf("%d",i);
            return 0;
        }
    }
 }

}

#include<stdio.h>
#include<math.h>
int main( )
{
	int n,i,j,k,a[1001],c=0,flag=0;
	scanf("%d",&n);
	for(i=1;i<=7;i++)
	{
		scanf("%d",&a[i]);
	}
	for(j=0;;j++)
	{
		for(i=1;i<=7;i++)
		{
			k+=a[i];
			c+=1;
			if(k>=n)
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
		{
			break;
		}
	}
	printf("%d\n",i);
	return 0;
}


#define ll long long
#define min(a,b) (a < b ? a : b)
typedef struct node {
    struct node * head[10];
    short cnt; char ed;
} n;
n * mk() {
    n * temp = malloc(sizeof(n));
    for (int i = 0; i < 10; i++)
        temp->head[i] = 0;
    temp->cnt = 0, temp->ed = '0';
    return temp;
}
n * fnd (n * tr, ll v) {
    while (v) {
        if (!tr->head[v%10]) tr->head[v%10] = mk();
        tr = tr->head[v%10];
        v/=10;
    }
    if (tr->ed == '0') tr->ed = '1', tr->cnt = 100;
    return tr;
}
void del (n * tr) {
    for (int i = 0; i < 10; i++)
        if (tr->head[i]) {
            del (tr->head[i]);
            free(tr->head[i]);
        }
}
n tr;
int dfs (ll v, int s) {
    ll k = v; int len = 0;
    while (k) len++, k/=10;
    if (len == s) return 0;
    else if (len > s) return 100;
    n * chk = fnd( &tr, v ); k = v;
    if (chk->cnt != 100) return chk->cnt;
    while (k) {
        if (k%10 > 1) chk->cnt = min(chk->cnt, 1 + dfs(v * (k%10), s));
        k/=10;
    } return chk->cnt;
}
int main () {
    for (int i = 0; i < 10; i++) tr.head[i] = 0;
    int m; ll f;
    scanf("%d%lld",&m,&f);
    int ans = dfs(f,m);
    printf("%d\n",(ans == 100) ? -1 : ans);
}

#include <stdio.h>

typedef long long ll;
#define rll register ll
#define rint register int
#define rep(i,a,b) for(rint i=(a);i<(b);i++)
#define repe(i,a,b) for(rint i=(a);i<=(b);i++)
#define repr(i,a,b) for(rint i=(a)-1;(b)<=i;i--)

int writeBuffer[20];
void write(ll num) { if (num == 0) putchar('0'); else { rint size = 0; rll current; if (0 < num) current = num; else current = -num, putchar('-'); while (0 < current) writeBuffer[size++] = current%10+'0', current /= 10; while (0 < size) putchar(writeBuffer[--size]); } }
ll read() { rint sign = 1; rll num = 0; while (1) { rint ch = getchar(); if (ch == '-') { sign = -sign; continue; } if (ch <= 32) break; num = num*10+(ch-'0'); } return sign*num; }

ll target;
int ans;
void dfs(ll num, int depth) {
    if (target <= num) ans = depth;
    else {
        rint best = depth;
        for (rll temp=num;temp<target;temp*=9) best++;
        if (best < ans) {
            rint mask = 0;
            for (rll temp=num;temp;temp/=10) mask |= 1<<(temp%10);
            rep(k,2,10) if (mask&(1<<k)) {
                rll newNum = num*k;
                dfs(newNum, depth+1);
            }
        }
    }
}

int main() {
    rint n = read();
    rll x = read();
    target = 1;
    rep(i,1,n) target *= 10;

    ans = 1000;
    dfs(x, 0);

    if (ans == 1000) putchar('-'), putchar('1');
    else write(ans);
}

#include <stdio.h>

int func (long long x, int n, int ans, int num, long long *pow10, long long *pow9) {
  int cnt = 0;
  int digit[10] = {};

  long long tmp = x;

  if (num >= ans) {
    return ans;
  }

  while (tmp > 0LL) {
    digit[(int)(tmp%10LL)] = 1;
    tmp /= 10LL;
    cnt++;
  }

  if (cnt > n) {
    return 100;
  }

  if (cnt == n) {
    return num;
  }

  for (int i = 9; i > 1; i--) {
    if (digit[i] > 0 && num <= ans-2) {
      long long nx = x*((long long)i);
      if (ans-num-2 >= n || (pow10[n-1]-1LL)/pow9[ans-num-2] < nx) {
        int tmp = func(nx, n, ans, num+1, pow10, pow9);
        if (tmp < ans) {
          ans = tmp;
        }
      }
    }
  }

  return ans;
}

int main () {
  int n = 0;
  long long x = 0LL;

  int res = 0;

  long long pow10[19] = {};
  long long pow9[19] = {};

  int ans = 0;

  res = scanf("%d", &n);
  res = scanf("%lld", &x);

  pow10[0] = 1LL;
  for (int i = 1; i < n; i++) {
    pow10[i] = 10LL*pow10[i-1];
  }

  pow9[0] = 1LL;
  for (int i = 1; i < n; i++) {
    pow9[i] = 9LL*pow9[i-1];
  }

  ans = func(x, n, 100, 0, pow10, pow9);
  if (ans >= 100) {
    ans = -1;
  }

  printf("%d\n", ans);

  return 0;
}

#define ll long long
#define min(a,b) (a < b ? a : b)
typedef struct node {
    struct node * head[10];
    short cnt; char ed;
} n;
n * mk() {
    n * temp = malloc(sizeof(n));
    for (int i = 0; i < 10; i++)
        temp->head[i] = 0;
    temp->cnt = 0, temp->ed = '0';
    return temp;
}
n * fnd (n * tr, ll v) {
    while (v) {
        if (!tr->head[v%10]) tr->head[v%10] = mk();
        tr = tr->head[v%10];
        v/=10;
    }
    if (tr->ed == '0') tr->ed = '1', tr->cnt = 100;
    return tr;
}
void del (n * tr) {
    for (int i = 0; i < 10; i++)
        if (tr->head[i]) {
            del (tr->head[i]);
            free(tr->head[i]);
        }
}
n tr;
int dfs (ll v, int s) {
    ll k = v; int len = 0;
    while (k) len++, k/=10;
    if (len == s) return 0;
    else if (len > s) return 100;
    n * chk = fnd( &tr, v ); k = v;
    if (chk->cnt != 100) return chk->cnt;
    while (k) {
        if (k%10 > 1) chk->cnt = min(chk->cnt, 1 + dfs(v * (k%10), s));
        k/=10;
    } return chk->cnt;
}
int main () {
    for (int i = 0; i < 10; i++) tr.head[i] = 0;
    int m; ll f;
    scanf("%d%lld",&m,&f);
    int ans = dfs(f,m);
    printf("%d\n",(ans == 100) ? -1 : ans);
    del(&tr);
}

#include <stdio.h>

int func (long long x, int n, int num, long long *pow10, int *lim) {
  int cnt = 0;
  int digit[10] = {};

  long long tmp = x;

  int ans = -1;

  while (tmp > 0LL) {
    digit[(int)(tmp%10LL)] = 1;
    tmp /= 10LL;
    cnt++;
  }

  if (cnt > n) {
    return -1;
  }

  if (cnt == n) {
    return num;
  }

  for (int i = 9; i > 1; i--) {
    if (digit[i] > 0) {
      long long nx = x*((long long)i);
      if (nx >= pow10[cnt] && lim[cnt] > num) {
        int tmp = 0;
        lim[cnt] = num+1;
        tmp = func(nx, n, num+1, pow10, lim);
        if (ans < 0 || (tmp >= 0 && tmp < ans)) {
          ans = tmp;
        }
      } else if (lim[cnt] > num+1) {
        int tmp = 0;
        tmp = func(nx, n, num+1, pow10, lim);
        if (ans < 0 || (tmp >= 0 && tmp < ans)) {
          ans = tmp;
        }
      }
    }
  }

  return ans;
}

int main () {
  int n = 0;
  long long x = 0LL;

  int res = 0;

  long long pow10[19] = {};
  int ans[20] = {};

  res = scanf("%d", &n);
  res = scanf("%lld", &x);

  pow10[0] = 1LL;
  for (int i = 1; i <= n; i++) {
    pow10[i] = 10LL*pow10[i-1];
  }

  for (int i = 0; i < n; i++) {
    ans[i] = 100;
  }

  printf("%d\n", func(x, n, 0, pow10, ans));

  return 0;
}

#include <stdio.h>

typedef unsigned long long ll;
#define rll register ll
#define rint register int
#define rep(i,a,b) for(rint i=(a);i<(b);i++)
#define repe(i,a,b) for(rint i=(a);i<=(b);i++)
#define repr(i,a,b) for(rint i=(a)-1;(b)<=i;i--)

int writeBuffer[20];
void write(ll num) { if (num == 0) putchar('0'); else { rint size = 0; rll current; if (0 < num) current = num; else current = -num, putchar('-'); while (0 < current) writeBuffer[size++] = current%10+'0', current /= 10; while (0 < size) putchar(writeBuffer[--size]); } }
ll read() { rint sign = 1; rll num = 0; while (1) { rint ch = getchar(); if (ch == '-') { sign = -sign; continue; } if (ch <= 32) break; num = num*10+(ch-'0'); } return sign*num; }

ll dp[100][1<<10];

int main() {
    rint n = read();
    rll target = 1;
    rep(i,0,n) target *= 10;

    rll x = read();

    {
        rint mask = 0;
        for (rll temp=x;temp;temp/=10) mask |= 1<<(temp%10);
        dp[0][mask] = x;
    }

    rint depth = 0;
    while (1) {
        rint found = 0;
        rep(j,0,1024) {
            rll num = dp[depth][j];
            if (num) {
                rep(k,2,10) if (j&(1<<k)) {
                    rll newNum = num*k;
                    if (target <= newNum) {
                        write(depth), putchar('\n');
                        return 0;
                    }
                    found = 1;
                    rint mask = 0;
                    for (rll temp=newNum;temp;temp/=10) mask |= 1<<(temp%10);
                    if (dp[depth+1][mask] < newNum) dp[depth+1][mask] = newNum;
                }
            }
        }
        if (!found) {
            putchar('-'), putchar('1'), putchar('\n');
            return 0;
        }
        depth++;
    }
}