#include <bits/stdc++.h>   using namespace std;   namespace Debug {   void __print(signed x) { cout << x; }   void __print(long x) { cout << x; }   void __print(long long x) { cout << x; }   void __print(unsigned x) { cout << x; }   void __print(unsigned long x) { cout << x; }   void __print(unsigned long long x) { cout << x; }   void __print(float x) { cout << x; }   void __print(double x) { cout << x; }   void __print(long double x) { cout << x; }   void __print(char x) { cout <<      << x <<     ; }   void __print(const char *x) { cout <<     << x <<    ; }   void __print(const string &x) { cout <<     << x <<    ; }   void __print(bool x) { cout << (x ?  true  :  false ); }   template <typename T, typename V>   void __print(const pair<T, V> &x) {     cout <<  { ;     __print(x.first);     cout <<  , ;     __print(x.second);     cout <<  } ;   }   template <typename T>   void __print(const T &x) {     long long f = 0;     cout <<  { ;     for (auto &i : x) cout << (f++ ?  ,  :   ), __print(i);     cout <<  } ;   }   void _print() { cout <<  ]  << endl; }   template <typename T, typename... V>   void _print(T t, V... v) {     __print(t);     if (sizeof...(v)) cout <<  ,  ;     _print(v...);   }   }  // namespace Debug   using namespace Debug;   const bool DEBUG = true;   long long calc_score(long long idx, long long n, long long k,                        vector<long long> &arr, long long time_left) {     long long score = 0ll;     for (long long i = 0; i < k; i++) {       for (long long j = idx; j <= n; j++) {         if (time_left < arr[i]) return score;         ++score;         time_left -= arr[i];       }     }     return score;   }   void process() {     long long n, k, M;     cin >> n >> k >> M;     vector<long long> arr(k);     for (long long i = 0; i < k; i++) cin >> arr[i];     long long res = 0ll, sum = accumulate(arr.begin() + 0, arr.begin() + k, 0ll);     sort(arr.begin() + 0, arr.begin() + k);     for (long long i = 0; i <= n; i++) {       if (sum * i > M) continue;       long long score = i * (k + 1);       long long time_left = M - (sum * i);       score += calc_score(i + 1, n, k, arr, time_left);       res = max(res, score);     }     cout << res <<   n ;   }   signed main() {     ios::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     ;     long long t = 1;     while (t--) process();     return 0;   }   