diff --git a/buggy.py b/buggy.py
--- a/buggy.py
+++ b/buggy.py
@@ -9,7 +9,7 @@
 
 class Solution:
     def maxPower(self, stations: List[int], r: int, k: int) -> int:
-        (start,)
+        start, end = min(stations), sum(stations) + k
         while start + 1 < end:
             mid = (start + end) // 2
             if self.check(stations, r, k, mid):
@@ -26,7 +26,7 @@
         ans = True
         newStations = defaultdict(int)
         power = sum(stations[:r])
-        for i in range(n + 1):
+        for i in range(n):
             if i + r < n:
                 power += stations[i + r]
             if i - r - 1 >= 0:
@@ -39,13 +39,9 @@
             else:
                 diff = target - power
                 power = target
-                stations[min(i + r, n - 1)] -= diff
+                stations[min(i + r, n - 1)] += diff
                 k -= diff
                 newStations[min(i + r, n - 1)] += diff
         for i in newStations:
             stations[i] -= newStations[i]
         return ans
-
-
-my_solution = Solution()
-my_solution.maxPower([1, 2, 3], 2, 5)
