Repeat and Missing Number (IBit)

class Solution:
    def repeatedNumber(self, A):
        N = len(A)
        Sn = ((1 + N) * N) // 2
        Sn2 = (N * (N + 1) * (2 * N + 1)) // 6
        total = 0
        total2 = 0
        for n in A:
            total = total + n
            total2 = total2 + (n ** 2)
        num1 = ((total - Sn) + (total2 - Sn2) // (total - Sn)) // 2
        num2 = num1 - (total - Sn)
        return [num1, num2]