diff --git a/buggy.py b/buggy.py
--- a/buggy.py
+++ b/buggy.py
@@ -21,5 +21,5 @@
         if need <= 0:
             ans = j
             break
-        need -= a[j]
+        need -= rest[j]
     print(ans)
