using System;

class GeometricProgression : Progression
{
    private int p0;
    private int q;

    public GeometricProgression(int p0, int q)
    {
        this.p0 = p0;
        this.q = q;
    }

    public override int GetElement(int k)
    {
        return p0 * (int)Math.Pow(q, k - 1);
    }

    public override int Sum(int n)
    {
        if (q == 1) return p0 * n;
        return p0 * (int)((Math.Pow(q, n) - 1) / (q - 1));
    }
}
