from typing import List


def summation_s(q: List[float]) -> float:
    """
    Calculate the summation for the improved letter frequency attack
    Input:
        q: the frequency of the ith letter of the alphabet in the ciphertext
    """
    S = 0
    for i in range(0, len(q)):
        S += pow(q[i], 2)
    return S