#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m, k;
cin >> n >> m >> k;
vector<int> a(m);
for (int i = 0; i < m; i++)
{
cin >> a[i];
}
for (int i = 0; i < m; i++)
{
if (a[i] > k)
{
cout << -1 << "\n";
return 0;
}
}
int cnt = 1;
int cur = 0;
for (int i = 0; i < m; i++)
{
if (cur + a[i] <= k)
{
cur += a[i];
}
else
{
cnt++;
cur = a[i];
}
}
int ans = n - cnt;
if (cnt > n)
{
ans = -1;
}
cout << ans << "\n";
return 0;
}