diff --git a/buggy.py b/buggy.py
--- a/buggy.py
+++ b/buggy.py
@@ -14,6 +14,6 @@
         for i in range(1, n):
             for j in range(i):
                 diff = nums[j] - nums[i]
-                dp[i][diff] = dp[j][diff] + 1
+                dp[i][diff] += dp[j][diff] + 1
                 total += dp[j][diff]
         return total
