from typing import FrozenSet
from typing import List


def get_weights(solution: FrozenSet[int], weights: List[int]):
    """
    Calculates and returns total weight of given knapsack solution
    :param solution: Knapsack solution consisting of packed items
    :param weights: profit of items
    :return: Total weight of given knapsack solution
    """
    return sum(weights[item - 1] for item in solution)