import sys
n, m, k = map(int, input().split())
a = [int(x) for x in input().split()]
for x in a:
if x > k:
print(-1)
sys.exit(0)
cnt = 1
cur = 0
for x in a:
if cur + x <= k:
cur += x
else:
cnt += 1
cur = x
ans = n - cnt
if cnt > n:
ans = -1
print(ans)