```python
def max_sub_array_sum_repeated(a, n, k):
    """
    Finds the largest sum of a contiguous subarray in an array formed by
    repeating the given array 'a' 'k' times.
    """
    if n == 0:
        return 0

    # Calculate the maximum subarray sum for a single instance of 'a'
    # using Kadane's algorithm. This covers cases where the max subarray
    # is entirely within one of the repeated blocks.
    max_sum_in_one_copy = a[0]
    current_max = a[0]
    for i in range(1, n):
        current_max = max(a[i], current_max + a[i])
        max_sum_in_one_copy = max(max_sum_in_one_copy, current_max)

    # If k is 1, the answer is simply the max subarray sum of 'a'.
    if k == 1:
        return max_sum_in_one_copy

    # For k > 1, we also need to consider subarrays that span across blocks.
    # This requires the total sum, max prefix sum, and max suffix sum of 'a'.

    # Calculate the maximum prefix sum and the total sum of 'a'.
    current_prefix_sum = 0
    max_prefix = -float('inf')
    for i in range(n):
        current_prefix_sum += a[i]
        max_prefix = max(max_prefix, current_prefix_sum)
    total_sum = current_prefix_sum

    # Calculate the maximum suffix sum of 'a'.
    current_suffix_sum = 0
    max_suffix = -float('inf')
    for i in range(n - 1, -1, -1):
        current_suffix_sum += a[i]
        max_suffix = max(max_suffix, current_suffix_sum)

    # Determine the final answer based on the total sum of 'a'.
    if total_sum <= 0:
        # If the sum of 'a' is not positive, including a full block in the middle
        # of a spanning subarray will not increase the sum. The maximum subarray
        # will span at most two blocks.
        # The candidates are a subarray within one block (max_sum_in_one_copy)
        # or a subarray crossing the boundary of two blocks (max_suffix + max_prefix).
        max_sum_across_two = max_suffix + max_prefix
        return max(max_sum_in_one_copy, max_sum_across_two)
    else:  # total_sum > 0
        # If the sum of 'a' is positive, it's beneficial to include all k-2
        # middle blocks in a spanning subarray.
        # The max sum from a spanning subarray would be:
        # (best suffix) + (sum of k-2 middle blocks) + (best prefix)
        max_spanning_sum = max_suffix + max_prefix + (k - 2) * total_sum
        # The final answer is the max of a subarray within one block vs. a spanning one.
        return max(max_sum_in_one_copy, max_spanning_sum)
```