#include <bits/stdc++.h>   using namespace std;   int gcd(int A, int B) {     if (B == 0)       return A;     else       return gcd(B, A % B);   }   long long int mod_exponentiation(long long int base, long long int exponent,                                    int modulus) {     long long int result = 1;     while (exponent > 0) {       if (exponent % 2 == 1) result = (result * base) % modulus;       exponent = exponent >> 1;       base = (base * base) % modulus;     }     return result;   }   int fermat(long long int n, long long int m) {     return mod_exponentiation(n, m - 2, m);   }   struct node {     int a;     int cnt;   };   struct Compare {     bool operator()(node &a, node &b) { return a.cnt > b.cnt; }   };   inline int toInt(string s) {     int v;     istringstream sin(s);     sin >> v;     return v;   }   template <class T>   inline string toString(T x) {     ostringstream sout;     sout << x;     return sout.str();   }   template <class T>   inline T sqr(T x) {     return x * x;   }   int main() {     int n;     cin >> n;     int a[8];     for (int i = 0; i < 7; i++) {       cin >> a[i + 1];     }     int sum = 0;     for (int i = 1; i <= 7;) {       sum += a[i];       if (sum >= n) {         cout << i;         return 0;       }       i++;       if (i > 7) {         i %= 7;       }     }   }   