diff --git a/buggy.py b/buggy.py
--- a/buggy.py
+++ b/buggy.py
@@ -128,7 +128,7 @@
     for i in range(1, N + 1):
         for a in A:
             if i - a >= 0:
-                dp[i] = a + (i - a) - dp[i - a]
+                dp[i] = max(dp[i], a + (i - a) - dp[i - a])
 
     # print(dp)
     print(dp[-1])
