from typing import List
import math


def even_groups(n: int, no_groups: int, rank_output: bool = False) -> List[int]:
    """
    returns an array of lengths normal out put
    e.g. even_groups(n=5, no_groups=2) -> [3,2]
    :param rank_output: default False; if True -> function returns an array of ranks not of group sizes
    e.g. even_groups(n=5, no_groups=2, rank_output=True) -> [1,1,1,2,2] instead of [3,2]
    :param n: total number of observations
    :param no_groups: expected amount of subgroups
    :return: List
    """

    output = []
    excess = n % no_groups

    for i in range(no_groups):
        output.append(math.floor(n / no_groups))

    for i in range(excess):
        output[i] += 1

    if not rank_output:
        return output
    else:
        rank_list = []
        for index in range(len(output)):
            for i in range(output[index]):
                rank_list.append(index + 1)
        return rank_list