import sys
import math

def main():
    N, M, L = map(int, sys.stdin.readline().split())
    A = list(map(int, sys.stdin.readline().split()))
    
    count = [0] * L
    
    for r in range(L):
        # Solve for t'*N ≡ r mod L
        g = math.gcd(N, L)
        if r % g != 0:
            count[r] = 0
            continue
        new_N = N // g
        new_L = L // g
        new_r = r // g
        
        # Find modular inverse of new_N modulo new_L
        try:
            inv_N = pow(new_N, -1, new_L)
        except ValueError:
            # Shouldn't happen as new_N and new_L are coprime
            count[r] = 0
            continue
        
        t0 = (new_r * inv_N) % new_L
        
        if t0 >= M:
            count[r] = 0
        else:
            # Number of solutions: floor((M-1 - t0) / new_L) + 1
            m_max = (M - 1 - t0) // new_L
            count[r] = m_max + 1
    
    max_C = -float('inf')
    for i in range(1, L+1):
        current_sum = 0
        for k in range(N):
            # j is k+1 in 1-based
            r = (i - (k+1)) % L
            current_sum += A[k] * count[r]
        if current_sum > max_C:
            max_C = current_sum
    print(max_C)

if __name__ == "__main__":
    main()