Pupils decided to go to amusement park. Some of them were with parents. In total, n people came to the park and they all want to get to the most extreme attraction and roll on it exactly once.Tickets for group of x people are sold on the attraction, there should be at least one adult in each group (it is possible that the group consists of one adult). The ticket price for such group is c1 + c2·(x - 1)2 (in particular, if the group consists of one person, then the price is c1). All pupils who came to the park and their parents decided to split into groups in such a way that each visitor join exactly one group, and the total price of visiting the most extreme attraction is as low as possible. You are to determine this minimum possible total price. There should be at least one adult in each group.

The first line contains three integers n, c1 and c2 (1 ≤ n ≤ 200 000, 1 ≤ c1, c2 ≤ 107) — the number of visitors and parameters for determining the ticket prices for a group. The second line contains the string of length n, which consists of zeros and ones. If the i-th symbol of the string is zero, then the i-th visitor is a pupil, otherwise the i-th person is an adult. It is guaranteed that there is at least one adult. It is possible that there are no pupils.

Print the minimum price of visiting the most extreme attraction for all pupils and their parents. Each of them should roll on the attraction exactly once.

NoteIn the first test one group of three people should go to the attraction. Then they have to pay 4 + 1 * (3 - 1)2 = 8.In the second test it is better to go to the attraction in two groups. The first group should consist of two adults (for example, the first and the second person), the second should consist of one pupil and one adult (the third and the fourth person). Then each group will have a size of two and for each the price of ticket is 7 + 2 * (2 - 1)2 = 9. Thus, the total price for two groups is 18.

import java.io.*;
import java.util.*;

public class Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

    class GraphBuilder {
        int n, m;
        int[] x, y;
        int index;
        int[] size;

        GraphBuilder(int n, int m) {
            this.n = n;
            this.m = m;
            x = new int[m];
            y = new int[m];
            size = new int[n];
        }

        void add(int u, int v) {
            x[index] = u;
            y[index] = v;
            size[u]++;
            size[v]++;
            index++;
        }

        int[][] build() {
            int[][] graph = new int[n][];
            for (int i = 0; i < n; i++) {
                graph[i] = new int[size[i]];
            }
            for (int i = index - 1; i >= 0; i--) {
                int u = x[i];
                int v = y[i];
                graph[u][--size[u]] = v;
                graph[v][--size[v]] = u;
            }
            return graph;
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine());
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long[] readLongArray(int size) throws IOException {
        long[] res = new long[size];
        for (int i = 0; i < size; i++) {
            res[i] = readLong();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Template().run();
        // new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    long calc(long c1, long c2, long x) {
        return c1 + c2 * (x - 1) * (x - 1);
    }

    void solve() throws IOException {
        int n = readInt();
        int c1 = readInt();
        int c2 = readInt();
        int cntV = 0;
        int cntC = 0;
        for (char x : readString().toCharArray()) {
            if (x == '1') cntV++;
            else cntC++;
        }

        long min = Long.MAX_VALUE;
        for (int g = 1; g <= cntV; g++) {
            long ost = n - g;
            long minSize = ost / g + 1;
            long rem = ost % g;
            long maxSize = minSize + 1;

            long answer = rem * calc(c1, c2, maxSize) + (g - rem) * calc(c1, c2, minSize);
            min = Math.min(min, answer);
        }
        out.println(min);
    }

}

import java.io.BufferedInputStream;
import java.util.Scanner;

/**
 * Created by leen on 4/8/17.
 */
public class _774A {

    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedInputStream(System.in, 1024 * 1024 * 64));

        long n = scan.nextInt(), c1 = scan.nextInt(), c2 = scan.nextInt();
        long na = 0;

        scan.nextLine();

        String flags = scan.nextLine();

        for(int i = 0; i < n; i++) {
            if (flags.charAt(i) == '1')
                na++;
        }

        long minNumGroups = 1, maxNumGroups = na;

        long minPrice = Long.MAX_VALUE;

        for(long numGroup = minNumGroups ; numGroup <= maxNumGroups; numGroup++)
            minPrice = Math.min(minPrice, minPrice(n, c1, c2, numGroup));

        System.out.println(minPrice);
    }

    // t * c1 + c2 * ( nl * (pl-1)^2 + ns * (ps-1)^2 )

    private static long minPrice(long n, long c1, long c2, long t) {
        long ps  = n / t;
        long pl = ps + 1;
        long nl = n % t;
        long ns = t - nl;

        return t * c1 + c2 * (nl * (pl-1) * (pl-1) + ns * (ps-1) * (ps-1));
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author toshif
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyReader in = new MyReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        private int n;
        private int c1;
        private int c2;

        public void solve(int testNumber, MyReader in, PrintWriter out) {
            n = in.nextInt();
            c1 = in.nextInt();
            c2 = in.nextInt();

            String s = in.next();
            int parent = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == '1') {
                    parent++;
                }
            }

            // ternary search
            long lo = 1, hi = parent;
            while (hi - lo > 1) {
                long mid = (lo + hi) / 2;
                if (f(mid) < f(mid + 1)) {
                    hi = mid;
                } else {
                    lo = mid;
                }
            }
            if (f(lo) < f(hi)) {
                out.println(f(lo));
            } else {
                out.println(f(hi));
            }

        }

        long f(long v) {
            long p1 = n / v;

            long sum = c1 * v;
            sum += (n % v) * c2 * (p1) * (p1);
            sum += (v - (n % v)) * c2 * (p1 - 1) * (p1 - 1);

            return sum;
        }

    }

    static class MyReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public MyReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import static java.lang.Math.abs;
import static java.lang.System.out;
import java.util.Scanner;

// 795A
// n people, some pupil, some adult. separate into groups. a group must have 1 adult
// if a group has x people, cost of tickets=c1+c2(x-1)^2
// optimize grouping to find minimal price
public class AmusementPark {

    int adult;
    int pupil;
    int n;      // 1 ≤ n ≤ 200 000
    long c1;    // 1 ≤ c1, c2 ≤ 10^7
    long c2;    // use long type to avoid overflow in calculation
    long minCost=0;

    long formula(int x)
    {
        return c1+c2*(x-1)*(x-1);
    }
    long calc(int group)
    {
        if (group==1)
        {
            return formula(n);
        }
        int avg = n/group;
        int rem = n%group;
        long cost = formula(avg);
        cost *= (group-rem);
        return cost + rem*formula(avg+1);
    }
    long cost(int lo, int hi, long lowCost, long hiCost)
    {
        if (abs(lo-hi)<=1) {
            //out.println("first "+lo+" second "+hi+" low clost "+lowCost+" hi cost "+hiCost);

            int temp=lo;
            while (temp>1) {
                long c=calc(--temp);
                if (c>lowCost)
                    break;
                lowCost=c;
            }
            temp=lo;
            while (temp<adult) {
                long c=calc(++temp);
                if (c>lowCost)
                    break;
                lowCost=c;
            }
            return lowCost;
        }
        int mid = (lo+hi)/2;
        long midCost = calc(mid);
        //out.println("first "+lo+" second "+hi+ " mid cost "+midCost+" low clost "+lowCost+" hi cost "+hiCost);
        if (midCost<lowCost)
            return cost(mid, lo, midCost, lowCost);
        else if ( midCost > lowCost )
            return cost(lo, mid, lowCost, midCost);
        else {
            //out.println("bad mid cost "+midCost+" low clost "+lowCost+" hi cost "+hiCost);
            return midCost;
        }
    }
    AmusementPark(int a, int p, int c1, int c2)
    {
        adult = a;
        pupil = p;
        n = a+p;
        this.c1 = c1;
        this.c2 = c2;
        long cost1 = calc(1);
        long cost2 = calc(a);
        if (cost1>cost2)
            cost1=cost(a, 1, cost2, cost1);
        else if (cost1<cost2)
            cost1=cost(1, a, cost1, cost2);
        //if (cost1==9343400)
        //    out.println("adult="+a+" pupil="+p+" cost1="+calc(1)+" cost2="+cost2);
        out.println(cost1);
    }

    static Scanner scan = new Scanner(System.in);
    static void judge()
    {
        int n = scan.nextInt();  // between 1 and 20000
        int c1 = scan.nextInt();  // between 1 and 10^7
        int c2 = scan.nextInt();  // between 1 and 10^7
        String people = scan.nextLine();
        if (people.isEmpty())
            people = scan.nextLine();
        int pupil=0;
        int adult=0;
        for(int i=0; i<people.length(); i++)
        {
            if (people.charAt(i)=='1')
                adult++;
            else
                pupil++;
        }
        new AmusementPark(adult, pupil, c1, c2);
    }
    static void test()
    {
        new AmusementPark(9559, 10442, 1000, 100); // 9333800
        new AmusementPark(9, 1, 2, 2); // 20
    }
    public static void main(String[] args)
    {
        judge();
    }
}
/*
10 2 2
1111101111
ans 20
*/

import static java.lang.Math.abs;
import static java.lang.System.out;
import java.util.Scanner;

// 795A
// n people, some pupil, some adult. separate into groups. a group must have 1 adult
// if a group has x people, cost of tickets=c1+c2(x-1)^2
// optimize grouping to find minimal price
// IDEA: binary search, local minimum may not be the best answer as we may have picked the wrong half
//  need to verify if there is no better solution
public class AmusementPark {

    int adult;
    int pupil;
    int n;      // 1 ≤ n ≤ 200 000
    long c1;    // 1 ≤ c1, c2 ≤ 10^7
    long c2;    // use long type to avoid overflow in calculation
    long minCost=0;

    long formula(int x)
    {
        return c1+c2*(x-1)*(x-1);
    }
    long calc(int group)
    {
        if (group==1)
        {
            return formula(n);
        }
        int avg = n/group;
        int rem = n%group;
        long cost = formula(avg);
        cost *= (group-rem);
        return cost + rem*formula(avg+1);
    }
    long cost(int lo, int hi, long lowCost, long hiCost)
    {
        if (abs(lo-hi)<=1) {
            //out.println("first "+lo+" second "+hi+" low clost "+lowCost+" hi cost "+hiCost);
            if (lo>1) {
                long c=calc(lo-1);
                if (c<lowCost)
                    return cost(lo-1, 1, c, calc(1));
            }
            if (lo<adult) {
                long c=calc(lo+1);
                if (c<lowCost)
                    return cost(lo+1, adult, c, calc(adult));
            }
            return lowCost;
        }
        int mid = (lo+hi)/2;
        long midCost = calc(mid);
        //out.println("first "+lo+" second "+hi+ " mid cost "+midCost+" low clost "+lowCost+" hi cost "+hiCost);
        if (midCost<lowCost)
            return cost(mid, lo, midCost, lowCost);
        else if ( midCost > lowCost )
            return cost(lo, mid, lowCost, midCost);
        else {
            //out.println("bad mid cost "+midCost+" low clost "+lowCost+" hi cost "+hiCost);
            return midCost;
        }
    }
    AmusementPark(int a, int p, int c1, int c2)
    {
        adult = a;
        pupil = p;
        n = a+p;
        this.c1 = c1;
        this.c2 = c2;
        long cost1 = calc(1);
        long cost2 = calc(a);
        if (cost1>cost2)
            cost1=cost(a, 1, cost2, cost1);
        else if (cost1<cost2)
            cost1=cost(1, a, cost1, cost2);
        out.println(cost1);
    }

    static Scanner scan = new Scanner(System.in);
    static void judge()
    {
        int n = scan.nextInt();  // between 1 and 20000
        int c1 = scan.nextInt();  // between 1 and 10^7
        int c2 = scan.nextInt();  // between 1 and 10^7
        String people = scan.nextLine();
        if (people.isEmpty())
            people = scan.nextLine();
        int pupil=0;
        int adult=0;
        for(int i=0; i<people.length(); i++)
        {
            if (people.charAt(i)=='1')
                adult++;
            else
                pupil++;
        }
        new AmusementPark(adult, pupil, c1, c2);
    }
    static void test()
    {
        new AmusementPark(9559, 10442, 1000, 100); // 9333800
        new AmusementPark(9, 1, 2, 2); // 20
    }
    public static void main(String[] args)
    {
        judge();
    }
}
/*
10 2 2
1111101111
ans 20
*/

import java.util.Scanner;

public class cf774A {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int c1=in.nextInt();
		int c2=in.nextInt();
		in.nextLine();
		String str=in.nextLine();

		int n0=0;
		int n1=0;

		for(int i=0;i<str.length();i++){
			if (str.charAt(i)=='0')
				n0++;
			if (str.charAt(i)=='1')
				n1++;
		}

		long min=getv(n,1,c1,c2);

		for (int i=2;i<=n1;i++){
			long temp = getv(n,i,c1,c2);
			if (temp<min)
				min=temp;
		}

		System.out.println(min);

	}

	static long getv(int n,int k,int c1,int c2){
		long temp;
		long t1=n/k;
		long t2=n%k;
		long tc1=(long) c1;
		long tc2=(long) c2;
		temp=tc1*k+t2*tc2*(t1*t1) + (k-t2)*tc2*(t1-1)*(t1-1);
		return temp;
	}

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Q1 {

	static long ans =0;
	static long min=Long.MAX_VALUE;
	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String input = r.readLine();

		String [] inp = input.split(" ");
		long n = Long.parseLong(inp[0]);
		long c1 = Long.parseLong(inp[1]);
		long c2 = Long.parseLong(inp[2]);

		input = r.readLine();
		long adults=0;
		long childs = 0;
		int i;
		for(i=0;i<input.length();i++){
			if (input.charAt(i)=='1')
				adults++;
			else
				childs++;
		}

		long ans = Long.MAX_VALUE;

		for(i=1;i<=adults;i++){
			long res = i*c1;
			long rem = n-i;
			long a = rem/i;
			long b = rem%i;

			res=res+c2*(i-b)*a*a+c2*b*(a+1)*(a+1);
			ans = Math.min(ans, res);
		}

		System.out.println(ans);

	}
}

import java.util.Scanner;

public class A{
	public static long sq(long x){
		return x * x;
	}

	public static long min(long a, long b){
		if (a < b){
			return a;
		}

		return b;
	}

    public static void main(String[] args) throws Exception{
    	Scanner scanner = new Scanner(System.in);
    	long n, c1, c2, x, a, p, i, ans;
    	String str;

    	n = scanner.nextLong();
    	c1 = scanner.nextLong();
    	c2 = scanner.nextLong();

    	a = 0;

    	str = scanner.next();

    	for (i = 0; i < n; i++){
    		if (str.charAt((int)i) == '1'){
    			a++;
    		}
    	}

    	ans = Long.MAX_VALUE;

    	for (i = 1; i <= a; i++){
    		p = n - i;
    		ans = min(ans, (p % i) * (c1 + c2 * sq((p / i) + 1)) + (i - (p % i)) * (c1 + c2 * sq(p / i)));
    	}

    	System.out.println(ans);

    	scanner.close();
    }
}

import java.io.*;
import java.util.StringTokenizer;

/**
 * Created by gamezovladislav on 21.03.2017.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = 1;
        for (int i = 0; i < n; i++) {
            solve(in, out);
        }
        out.close();
    }

    private static void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        long c1 = in.nextLong();
        long c2 = in.nextLong();
        String s = in.next();
        int cnt1 = 0;
        int cnt0 = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '0') cnt0++;
            else cnt1++;
        }
        long answer = c1 + c2 * (n - 1) * (n - 1);
        for (long i = 1; i <= cnt1; i++) {
            long x1 = n / i;
            long ans1 = c1 + c2 * (x1 - 1) * (x1 - 1);
            long x2 = n / i + 1;
            long ans2 = c1 + c2 * (x2 - 1) * (x2 - 1);
            ans1 *= i - (n%i);
            ans2 *= (n % i);
            answer = StrictMath.min(answer, ans1+ans2);
        }
        out.print(answer);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

}

import java.io.*;
import java.util.StringTokenizer;

/**
 * Created by gamezovladislav on 21.03.2017.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = 1;
        for (int i = 0; i < n; i++) {
            solve(in, out);
        }
        out.close();
    }

    private static void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        long c1 = in.nextLong();
        long c2 = in.nextLong();
        String s = in.next();
        int cnt1 = 0;
        int cnt0 = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '0') cnt0++;
            else cnt1++;
        }
        long answer = c1 + c2 * (n - 1) * (n - 1);
        for (long i = 1; i <= cnt1; i++) {
            long x1 = n / i;
            long ans1 = c1 + c2 * (x1 - 1) * (x1 - 1);
            long x2 = n / i + 1;
            long ans2 = c1 + c2 * (x2 - 1) * (x2 - 1);

            long d2 = n % i;
            long d1 = i - d2;
            ans1 *= d1;
            ans2 *= d2;
            answer = StrictMath.min(answer, ans1+ans2);
        }
        out.print(answer);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class D {

	static int n, c1, c2;

	public static void main(String[] args) throws IOException
	{
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		n = sc.nextInt(); c1 = sc.nextInt(); c2 = sc.nextInt();
		int one = 0;
		char[] a = sc.next().toCharArray();
		for(int i = 0; i < n; i++)
			if(a[i] == '1') one++;
		int lo = 1, hi = one;
		long ans = -1;
		while(lo <= hi)
		{
			int telt = lo + (hi - lo) / 3;
			int telten = hi - (hi - lo) / 3;
			long teltCost = can(telt), teltenCost = can(telten);
			if(teltCost == teltenCost) {ans = teltCost; break;}
			else if(teltCost < teltenCost)
			{
				ans = teltCost;
				hi = telten - 1;
			}
			else
			{
				ans = teltenCost;
				lo = telt + 1;
			}
		}
		out.println(ans);
		out.flush();
		out.close();
	}

	static long can(int groups)
	{
		int div = n / groups, rem = n % groups;
		long cost = (c1 + (c2 * sq(div - 1))) * (groups - rem);
		cost += (c1 + (c2 * sq(div))) * rem;
		return cost;
	}

	static long sq(long x)
	{
		return x * x;
	}

	static class Scanner
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream System){	br = new BufferedReader(new InputStreamReader(System));	}
		public String next() throws IOException
		{
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine()throws IOException{return br.readLine();}
		public int nextInt() throws IOException {return Integer.parseInt(next());}
		public double nextDouble() throws IOException {return Double.parseDouble(next());}
		public char nextChar()throws IOException{return next().charAt(0);}
		public Long nextLong()throws IOException{return Long.parseLong(next());}
		public boolean ready() throws IOException{return br.ready();}
		public void waitForInput(){for(long i = 0; i < 3e9; i++);}
	}
}

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);

	    int n = sc.nextInt();

	    int c1 = sc.nextInt();
	    int c2 = sc.nextInt();

	    String jj= sc.nextLine();
	    String ss = sc.nextLine();

	    int one=0;

	    for(int i=0;i<n;i++) if(ss.charAt(i)=='1') one++;

	    long sz=one;
	    long ans=Long.MAX_VALUE;

	    while(sz>0)
	    {
	        long  loc;

	        long val = n%sz;

	        long trm = n/sz;

	        loc = sz*c1;

	        loc = loc + c2*val*trm*trm;

	        loc = loc + c2*(sz-val)*(trm-1)*(trm-1);

	         if(loc<ans)
	           ans=loc;

	        sz--;
	    }

	    System.out.println(ans);

	}
}

import java.io.*;
import java.util.*;
import java.math.*;
public class Main{
	public static void main(String args[]) throws IOException{
		Scanner sc = new Scanner(System.in);
		int n; long A, B;
		n = sc.nextInt(); A = sc.nextLong(); B = sc.nextLong();
		String S;
		S = sc.next();
		int pu = 0, ad = 0;
		for(int i = 0; i < n; i++){
			if(S.charAt(i) == '0') pu++;
			else ad++;
		}
		long best = Long.MAX_VALUE;
		for(int i = 1; i <= ad; i++){
			long ans = A*i;
			int cap = n/i, res = n%i;
			long cost = ans + (i - res)*B*(cap - 1)*(cap - 1) + res*B*cap*cap;
			best = Math.min(best, cost);
		}
		System.out.println(best);
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by demich on 14.03.17.
 */
public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String buf = in.readLine();
        String sp[] = buf.split(" ");
        int n = Integer.parseInt(sp[0]);
        long c1 = Integer.parseInt(sp[1]), c2 = Integer.parseInt(sp[2]);
        String str = in.readLine();

        int a = 0, b = 0;
        for(char c : str.toCharArray()){
            if(c=='1') ++a; else  ++b;
        }

        long ans = Long.MAX_VALUE;

        for(int x=1;x<=n;++x){
            int cnt = n / x;
            if(n%x!=0) ++cnt;

            if(cnt>a) continue;

            int full = n % cnt;
            if(full==0) full = cnt;

            long res = full * (c1 + c2 * (x-1) * (x-1));
            res+=(cnt-full) * (c1 + c2 * (x-2) * (x-2));

            ans = Math.min(ans, res);
        }

        for(int cnt=1;cnt<=a;++cnt){
            int x = n / cnt;
            if(n%cnt!=0) ++x;

            int full = n % cnt;
            if(full==0) full = cnt;

            long res = full * (c1 + c2 * (x-1) * (x-1));
            res+=(cnt-full) * (c1 + c2 * (x-2) * (x-2));

            ans = Math.min(ans, res);
        }

        System.out.println(ans);
        System.out.flush();

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            int c1 = in.nextInt();
            int c2 = in.nextInt();

            char[] c = in.next().toCharArray();
            int a1 = 0, a2 = 0;
            for (char x : c) {
                if (x == '0') a1++;
                else a2++;
            }

            long best = c1 + 1L * c2 * (n - 1) * (n - 1);
            for (int numgroups = 1; numgroups <= a2; numgroups++) {
                int sz = n / numgroups;
                int m = n % numgroups;
                long cur = 1L * numgroups * c1;
                cur += 1L * c2 * (sz - 1) * (sz - 1) * (numgroups - m);
                cur += 1L * c2 * sz * sz * m;
                best = Math.min(best, cur);
            }

            out.println(best);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (this.numChars == -1) {
                throw new InputMismatchException();
            } else {
                if (this.curChar >= this.numChars) {
                    this.curChar = 0;

                    try {
                        this.numChars = this.stream.read(this.buf);
                    } catch (IOException var2) {
                        throw new InputMismatchException();
                    }

                    if (this.numChars <= 0) {
                        return -1;
                    }
                }

                return this.buf[this.curChar++];
            }
        }

        public int nextInt() {
            int c;
            for (c = this.read(); isSpaceChar(c); c = this.read()) {
                ;
            }

            byte sgn = 1;
            if (c == 45) {
                sgn = -1;
                c = this.read();
            }

            int res = 0;

            while (c >= 48 && c <= 57) {
                res *= 10;
                res += c - 48;
                c = this.read();
                if (isSpaceChar(c)) {
                    return res * sgn;
                }
            }

            throw new InputMismatchException();
        }

        public String next() {
            int c;
            while (isSpaceChar(c = this.read())) {
                ;
            }

            StringBuilder result = new StringBuilder();
            result.appendCodePoint(c);

            while (!isSpaceChar(c = this.read())) {
                result.appendCodePoint(c);
            }

            return result.toString();
        }

        public static boolean isSpaceChar(int c) {
            return c == 32 || c == 10 || c == 13 || c == 9 || c == -1;
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(long i) {
            writer.println(i);
        }

    }
}

import java.util.*;

public class A{
    public static void main(String[] argc){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int c1 = sc.nextInt();
        int c2 = sc.nextInt();
        String s = sc.next();
        int cnt = 0;
        for (int i = 0; i < n; i++) if (s.charAt(i) == '1') cnt++;
        long ans = (long)1e18;
        for (int i = 1; i <= cnt; i++) {
            int less = n - i;
            int k = less / i;
            int k2 = less % i;
            int k1 = i - k2;
            long tans = k1 * (c1 + (long)c2 * k * k) + k2 * (c1 + (long)c2 * (k + 1) * (k + 1));
            if (tans < ans) ans = tans;
        }
        System.out.println(ans);
    }
}

import java.util.*;
import java.io.*;

public class A {
    FastScanner in;
    PrintWriter out;

    public void solve() throws IOException {
        int n = in.nextInt();
        long c1 = in.nextInt();
        long c2 = in.nextInt();
        int s = (int) in.next().chars().filter(x -> x == '0').count();
        int p = n - s;
        long ans = Long.MAX_VALUE;
        for (int i = 1; i <= p; i++) {
            int rest = n - i;
            int cc1 = rest % i;
            long cnt1 = c1 + c2 * (rest / i + 1L) * (rest / i + 1L);
            int cc2 = i - cc1;
            long cnt2 = c1 + c2 * ((long) rest / i) * ((long) rest / i);
            long curAns = cc1 * cnt1 + cc2 * cnt2;
            ans = Math.min(ans, curAns);
        }
        out.println(ans);
    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);
            Locale.setDefault(Locale.US);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        FastScanner(InputStream f) {
            br = new BufferedReader(new InputStreamReader(f));
        }

        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }

    public static void main(String[] arg) {
        new A().run();
    }
}

import java.util.HashSet;
import java.util.Scanner;

public class BUNT
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int c1 = scan.nextInt();
		int c2 = scan.nextInt();
		String s = scan.nextLine();
		s = scan.nextLine();
		int a = 0, b = 0;
		for (int i = 0; i < n; i++)
		{
		    if (s.charAt(i) == '1')
		    {
		        a++;
		    }
		    else
		    {
		        b++;
		    }
		}
		long ans = Long.MAX_VALUE;
		for (int cnt = 1; cnt <= a; cnt++)
		{
		    int other = b + a - cnt;
		    int kek = other / cnt;
		    long res = c1 * (long) cnt;
		    int ost = other % cnt;
		    res += (cnt - ost) * (long) kek * (long) kek * (long) c2;
		    res += ost * (long) (kek + 1) * (long) (kek + 1) * (long) c2;
		    ans = Math.min(ans, res);
		}
		System.out.println(ans);
	}
}

import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int c1=sc.nextInt();
        int c2=sc.nextInt();
        String s=sc.next();
        int cnt=0;
        for (int i = 0; i < n; i++)
            if(s.charAt(i)=='1')
                cnt++;
        long ans=(long)1e18;
        for (int i=1;i<=cnt;i++)
        {
            int x=n/i;
            int y=n%i;
            long tempans=(c1+(long)c2*x*x)*y;
            tempans+=(c1+(long)c2*(x-1)*(x-1))*(i-y);
            if (tempans<ans)
                ans=tempans;
        }
        System.out.println(ans);
    }
}

import java.util.*;

public class Main{
	public static long min(long a, long b){
		return a<b?a:b;
	}
	public static void main(String[] argc){
		Scanner sc = new Scanner(System.in);
		long n=sc.nextInt();
		long c=0;
		long a=0;
		long c1=sc.nextInt();
		long c2=sc.nextInt();
		String s=sc.next();
		for(int i=0; i<n; i++)
			if(s.charAt(i)=='1')
				a++;
		long ans=c1+c2*(n-1)*(n-1);
		for(long i=2; i<=a; i++){
			c=n-i;
			if(c%i==0){
				c/=i;
				ans=min(ans, c1*i+c2*c*c*i);
			}
			else{
				long cc=c%i;
				c/=i;
				ans=min(ans, c1*i+c2*(cc*(c+1)*(c+1)+(i-cc)*c*c));
			}
		}
		System.out.println(ans);
	}
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
      /*  InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);*/
        TaskC solver = new TaskC();
        solver.solve();
        //out.close();
    }

    static class TaskC {
        static final int INF = (int) 1e9;

        public void solve() {
						Scanner in = new Scanner(System.in);
            int n = in.nextInt();
						int c1i = in.nextInt();
						int c2i = in.nextInt();
            String s = in.next();
            int pars_i = 0;
           // int[] kpos = new int[n];

            for (int i = 0; i < n; ++i) {
                char ch = s.charAt(i);
                if (ch == '1') {
									++pars_i;
                }
            }
						long pars = pars_i;
						long kids = n-pars;
						long c1 = c1i;
						long c2 = c2i;
						long sol = c1 + c2*(n-1)*(n-1);
						for (long teams = 2; teams <= pars; ++teams) {
							long left = n-teams;
							if (left == 0) {
								if (sol < 0) sol = c1 * teams;
								sol = Math.min(sol, c1 * teams);
								continue;
							}
							long y = left/teams;
							long yplus1nums = left%teams;
							long cur = c1*teams + c2*(y*y*(teams-yplus1nums) + (y+1)*(y+1)*yplus1nums);
							if (sol < 0) sol = cur;
							if (cur >= 0) {
								sol = Math.min(sol, cur);
							}
						}

						/*
            int[][][][] best = new int[2][nk + 1][nv + 1][no + 1];
            for (int[][][] x : best) for (int[][] y : x) for (int[] z : y) Arrays.fill(z, INF);
            best[0][0][0][0] = 0;
            for (int k = 0; k <= nk; ++k) {
                for (int v = 0; v <= nv; ++v) {
                    for (int o = 0; o <= no; ++o) {
                        for (int hv = 0; hv < 2; ++hv) {
                            int cur = best[hv][k][v][o];
                            if (k < nk && hv == 0) {
                                best[0][k + 1][v][o] = Math.min(best[0][k + 1][v][o], cur + Math.abs(snv[kpos[k]] - v) + Math.abs(sno[kpos[k]] - o));
                            }
                            if (v < nv) {
                                best[1][k][v + 1][o] = Math.min(best[1][k][v + 1][o], cur + Math.abs(snk[vpos[v]] - k) + Math.abs(sno[vpos[v]] - o));
                            }
                            if (o < no) {
                                best[0][k][v][o + 1] = Math.min(best[0][k][v][o + 1], cur + Math.abs(snv[opos[o]] - v) + Math.abs(snk[opos[o]] - k));
                            }
                        }
                    }
                }
            }*/

            System.out.println(sol);
        }

    }
}

import java.util.Scanner;

public class Solver {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);

		int n = input.nextInt();
		long c1 = input.nextLong();
		long c2 = input.nextLong();
		String s = input.next();

		int adults = 0;

		for (int i = 0; i < n; ++i)
			if (s.charAt(i) == '1')
				++adults;

		long ans = Long.MAX_VALUE, cnt, rem, sum;

		for (int g = 1; g <= adults; ++g) {
			cnt = (n - g) / g;
			rem = (n - g) % g;
			sum = c1 * g + c2 * rem * (cnt + 1) * (cnt + 1) + c2 * (g - rem) * cnt * cnt;
			ans = Math.min(ans, sum);
		}

		System.out.println(ans);
	}
}

import java.util.Scanner;

public class StringTask {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int A = in.nextInt();
        int B = in.nextInt();
        String s = in.next();
        int cnt = 0;
        for (int i=0; i<n; i++)
            if (s.charAt(i) == '1')
                cnt++;
        long res = ((long)(1000))*1000*1000*1000*1000*1000;
        for (long i=1; i<=cnt; i++)
        {
            long x = (n - i) / i;
            long y = (n - 1) / i;
            long Y = (n - i) % i;
            long X = i - Y;
            long now = A * i + ((X * x * x) + (Y * y * y)) * B;
            if (res > now)
                res = now;
        }
        System.out.println(res);
    }
}

import java.io.*;
import java.math.*;
import java.security.KeyStore.Entry;
import java.util.*;

public class TestClass {
	private InputStream is;
	private PrintWriter out;
	private String INPUT = "";

	long n,c1,c2;
	long ans(long p){
		long an = 0;
		long pe = n/p;
		long rem = n%p;
		an+=p*c1;
		an+=c2*(p-rem)*(pe-1)*(pe-1);
		an+=c2*rem*pe*pe;
		return an;
	}
	void solve() {
		n = ni();
		c1 = ni();
		c2 = ni();
		String b = ns();
		long count = 0;
		for(int i=0;i<b.length();i++)
			if(b.charAt(i)=='1')
				count++;
		long l = 1,r = count;
		long ans = Long.MAX_VALUE;
		while(l<=r){
			long x = l+(r-l)/3;
			long y = r-(r-l)/3;
			long temp1 = ans(x);
			long temp2 = ans(y);
			if(temp1<temp2){
				r = y-1;
				ans = Math.min(ans, temp1);
			}
			else{
				l = x+1;
				ans = Math.min(ans, temp2);
			}
		}
		out.println(ans);
	}

	void run() throws Exception {
		is = System.in;
		out = new PrintWriter(System.out);
		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Thread(null, new Runnable() {
			public void run() {
				try {
					new TestClass().run();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
	}

	// To Get Input
	// Some Buffer Methods
	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != '
									// ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;

	private void tr(Object... o) {
		if (!oj)
			System.out.println(Arrays.deepToString(o));
	}
}

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class SuffixArray {
    private static InputStream stream;
    private static byte[] buf = new byte[1024];
    private static int curChar;
    private static int numChars;
    private static SpaceCharFilter filter;
    private static PrintWriter pw;
    private static long mod = 1000000000+7;
    private static long mod1=(long) Math.pow(2,63);
    private static void soln(){
    	long n=nextLong();
    	long c1=nextLong();
    	long c2=nextLong();
    	String s=nextLine();
    	long cnt=0;
    	long max=Long.MAX_VALUE;
    	for(int i=0;i<s.length();i++)
    		cnt+=s.charAt(i)-'0';
    	for(long i=1;i<=cnt;i++){
    		long avg=n/i;
    		long cnt1=n%i;
    		long price;
    		price=cnt1*(c1+c2*(avg)*(avg));
    		price+=(i-cnt1)*(c1+c2*(avg-1)*(avg-1));
    		max=Math.min(max,price);
    		//System.out.println(max);
    	}
    	pw.println(max);
    }
   /* private static void BFS(LinkedList<Integer>[] l,int[] co,int n,int[] pa){
    	Queue<Integer> q=new LinkedList<>();
    	q.add(0);
    	pa[0]=-1;
    	int k=1;
    	co[0]=k;
    	while(!q.isEmpty()){
    		int cur=q.poll();
    		int prev=pa[cur];
    		k=1;
    		Iterator<Integer> i=l[cur].listIterator();
    		while(i.hasNext()){
    			//System.out.println((cur+1));
    			int x=i.next();
    			if(x!=prev){
    				q.add(x);
    				while(k==co[cur] || (prev!=-1 && k==co[prev]))
    					k++;
    				co[x]=k++;
    				pa[x]=cur;
    				//max=Math.max(max,k);
    			}
    		}
    	}
    	max=co[0];
    	for(int i=1;i<n;i++)
    		max=Math.max(co[i],max);
    	pw.println(max);
    	for(int i=0;i<n;i++)
    		pw.print(co[i]+" ");
    }*/
    static class Pair implements Comparable<Pair>{
    	int x,y;
    	public Pair(int a,int b){
    		x=a;
    		y=b;
    	}
		@Override
		public int compareTo(Pair arg0) {
			return (this.x-arg0.x);
		}
    }
        public static int fun(Node root,int xor){
    	Node tmp=root;
    	int temp=xor;
    	int[] arr=new int[28];
    	for(int i=0;i<=27;i++){
    		arr[i]=temp%2;
    		temp=temp/2;
    	}
    	for(int i=27;i>=0;i--){
    		int val= arr[i];
    		if(tmp.arr[1-val]!=null)
    			tmp=tmp.arr[1-val];
    		else if(tmp.arr[val]!=null)
    			tmp=tmp.arr[val];
    	}
    	return xor^(tmp.val);
    }
    public static void insert(Node root,int xor){
    	Node temp=root;
    	int tmp=xor;
    	int[] arr=new int[28];
    	for(int i=0;i<=27;i++){
    		arr[i]=tmp%2;
    		tmp=tmp/2;
    	}
    	for(int i=27;i>=0;i--){
    		int val= arr[i];
    		if(temp.arr[val]==null){
    			temp.arr[val]=new Node();
    		}
    		temp=temp.arr[val];
    	}
    	temp.val=xor;
    }
    public static class Node{
    	int val;
    	Node[] arr;
    	public Node(){
    		arr=new Node[2];
    		val=0;
    		arr[1]=null;
    		arr[0]=null;
    	}
    }
	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
	/*public static long dijsktra(LinkedList<Pair>[] l,LinkedList<Pair>[] l1,int n){
    	long ans=0;
    	PriorityQueue<Pair> q = new PriorityQueue<>();
    	int[] arr=new int[n];
    	Arrays.fill(arr,Integer.MAX_VALUE);
   	 	arr[0]=0;
   	 	q.add(new Pair(0, 0));
   	 	while(!q.isEmpty()){
   			Pair p = q.poll();
   			for(Pair x:l[p.x]){
   				if(arr[x.x]>(arr[p.x]+x.w)){
   					arr[x.x] = (arr[p.x]+x.w);
   					q.add(new Pair(x.x,arr[x.x]));
	   			}
	   		}
	   	}
   	 	boolean[] visited=new boolean[n];
	   	visited[0] = true;
	   	PriorityQueue<Integer> q1=new PriorityQueue();
		q1.add(0);
		while(!q1.isEmpty()){
		int y = q1.poll();
			for(Pair g:l1[y]){
				if(!visited[g.x]){
					ans+=Math.max(0, Math.min(arr[y]+g.w-arr[g.x],arr[g.x]+g.w-arr[y]));
					visited[g.x] = true;
					q1.add(g.x);
				}else{
					ans+=Math.max(0, Math.min(arr[y]+g.w-arr[g.x],arr[g.x]+g.w-arr[y]));
				}
			}
		}
		//System.out.println(ans);
		return ans;
   	}*/
	private static long mat_power(long[][] matrix,long n){
		long[][] temp={{1,1,1},{1,0,0},{0,0,2}};
		if(n==1)
			return 3;
		mat_power(matrix,n/2);
		matrix_multiplication(matrix,matrix);
		if(n%2!=0){
			matrix_multiplication(matrix,temp);
		}
		return (matrix[0][0]+2*matrix[0][2])%mod;
	}
	private static void matrix_multiplication(long[][] a,long[][] b){
		long[][] result=new long[3][3];
		for(int i = 0 ; i < 3 ; i ++)
	        for(int j = 0 ; j < 3 ; j++)
	            for(int k = 0 ; k < 3 ; k++)
	                result[i][j] = (result[i][j] + a[i][k]*b[k][j]) % mod;
	    for(int i = 0 ; i < 3 ; i++)
	        for(int j = 0 ; j < 3 ; j++)
	            a[i][j] = result[i][j];
	}
    private static long power(long x,long y,long mod){
    	long ans = 1;
		while(y>0){
			if(y%2==1){
			    if(ans>mod/x) return -1;
				ans*=x;
				y-=1;
			}
			else{
			    if(x>mod/x) return -1;
				x*=x;
				y/=2;
			}
		}
		return ans;
    }
    public static class Suffix implements Comparable<Suffix>{
        int index;
        int[] rank=new int[2];
        @Override
        public int compareTo(Suffix arg0){
            return (this.rank[0]==arg0.rank[0])?(this.rank[1]<arg0.rank[1]?-1:1):(this.rank[0]<arg0.rank[0]?-1:1);
        }
    }
    private static int[] buildSuffix(String s,int n){
        Suffix[] arr=new Suffix[n];
        for(int i=0;i<n;i++)
            arr[i]=new Suffix();
        for(int i=0;i<n;i++){
            arr[i].index=i;
            arr[i].rank[0]=s.charAt(i)-'a';
            arr[i].rank[1]=((i+1)<n)?(s.charAt(i+1)-'a'):-1;
        }
        Arrays.sort(arr);
        //for(int i=0;i<n;i++)
            //System.out.print(arr[i].index);
        int[] ind=new int[n];
        for(int k=4;k<2*n;k=k*2){
            int rank=0;
            int p_rank=arr[0].rank[0];
            arr[0].rank[0]=rank;
            ind[arr[0].index]=0;
            for(int i=1;i<n;i++){
                if (arr[i].rank[0] == p_rank && arr[i].rank[1] == arr[i-1].rank[1]) {
                    p_rank = arr[i].rank[0];
                    arr[i].rank[0] = rank;
                }
                else{
                    p_rank = arr[i].rank[0];
                    arr[i].rank[0] = ++rank;
                }
                ind[arr[i].index] = i;
            }
            for(int i=0;i<n;i++){
                int n_index=arr[i].index + k/2;
                arr[i].rank[1]=(n_index<n)?arr[ind[n_index]].rank[0] : -1;
            }
            Arrays.sort(arr);
        }
        int[] suffixArr=new int[n];
        for(int i=0;i<n;i++)
            suffixArr[i]=arr[i].index;
        return suffixArr;
    }
    private static long pow(long a, long b,long mod) {
        if (b == 0)
            return 1;
        long p = pow(a, b / 2,mod);
        p = (p * p)%mod;
        return (b % 2 == 0) ? p : (a * p)%mod;
    }
    private static long gcd(long x, long y) {
        if (y == 0)
            return x;
        return gcd(y, x % y);
    }

    private static long max(long a, long b) {
        if (a > b)
            return a;
        return b;
    }

    private static long min(long a, long b) {
        if (a < b)
            return a;
        return b;
    }

    public static void main(String[] args) throws Exception {
    	new Thread(null, new Runnable() {
			public void run() {
				try {
					InputReader(System.in);
			        pw = new PrintWriter(System.out);
			        soln();
			        pw.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
    }

    public static void InputReader(InputStream stream1) {
        stream = stream1;
    }

    private static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private static boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    private static int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    private static int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    private static long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    private static String nextToken() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    private static String nextLine() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    private static int[] nextIntArray(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }
        return arr;
    }

    private static long[] nextLongArray(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextLong();
        }
        return arr;
    }

    private static void pArray(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        return;
    }

    private static void pArray(long[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        return;
    }

    private static boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }

    private interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

import java.util.*;

public class A{
    public static void main(String[] argc){

      String s;
      int n, oldman=0, i;
      long c1, c2, ans = Long.MAX_VALUE, a1, b1, q;

      Scanner sc = new Scanner(System.in);
      n = sc.nextInt(); c1 = sc.nextLong(); c2 = sc.nextLong();
      s = sc.next();
      for (i = 0; i < n; i++) if (s.charAt(i) == '1') oldman++;

      for (i = 1; i <= oldman; i++) {
	   q=n-i; a1 = q/i; b1 = n % i;
	   q = c1 * i + c2 * (a1 * a1 * i + b1 * ((a1+1) * (a1+1) - a1 * a1));
           if (q<ans) ans=q;
      }
      System.out.println(ans);
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author toshif
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyReader in = new MyReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        private int n;
        private int c1;
        private int c2;

        public void solve(int testNumber, MyReader in, PrintWriter out) {
            n = in.nextInt();
            c1 = in.nextInt();
            c2 = in.nextInt();

            String s = in.next();
            int parent = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == '1') {
                    parent++;
                }
            }

            // ternary search
            long lo = 1, hi = parent;
            while (hi - lo > 1) {
                long mid = (lo + hi) / 2;
                if (f(mid) > f(mid + 1)) {
                    hi = mid;
                } else {
                    lo = mid;
                }
            }
            if (f(lo) < f(hi)) {
                out.println(f(lo));
            } else {
                out.println(f(hi));
            }

        }

        long f(long v) {
            long p1 = n / v;

            long sum = c1 * v;
            sum += (n % v) * c2 * (p1) * (p1);
            sum += (v - (n % v)) * c2 * (p1 - 1) * (p1 - 1);

            return sum;
        }

    }

    static class MyReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public MyReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import static java.lang.System.out;
import java.util.Scanner;

// 795A
// n people, some pupil, some adult. separate into groups. a group must have 1 adult
// if a group has x people, cost of tickets=c1+c2(x-1)^2
// find minimal price
public class AmusementPark {

    int adult;
    int pupil;
    int n;
    int c1;
    int c2;
    long minCost=0;

    long formula(int x)
    {
        return c1+c2*(x-1)*(x-1);
    }
    long calc(int group)
    {
        if (group==1)
        {
            return formula(n);
        }
        int avg = n/group;
        int rem = n%group;
        long cost = formula(avg);
        if ( rem>0 ) {
            cost *= (group-rem);
            return cost + rem*formula(avg+1);
        }
        else
            return cost *group;
    }
    long cost(int lo, int hi, long lowCost, long hiCost)
    {
        if (lo-hi<=1 && lo-hi>=-1) {
            return lowCost;
        }
        int mid = (lo+hi)/2;
        long midCost = calc(mid);
        //out.println("first "+lo+" second "+hi+ " mid cost "+midCost+" low clost "+lowCost+" hi cost "+hiCost);
        if (midCost<lowCost)
            return cost(mid, lo, midCost, lowCost);
        else if ( midCost < hiCost )
            return cost(lo, mid, lowCost, midCost);
        else {
            //out.println("bad mid cost "+midCost+" low clost "+lowCost+" hi cost "+hiCost);
            return midCost;
        }
    }
    AmusementPark(int a, int p, int c1, int c2)
    {
        adult = a;
        pupil = p;
        n = a+p;
        this.c1 = c1;
        this.c2 = c2;
        long cost1 = calc(1);
        long cost2 = calc(a);
        if (cost1>cost2)
            out.println(cost(a, 1, cost2, cost1));
        else if (cost1<cost2)
            out.println(cost(1, a, cost1, cost2));
        else
            out.println(cost1);
    }

    static Scanner scan = new Scanner(System.in);
    static void autoTest()
    {
        int n = scan.nextInt();  // between 1 and 20000
        int c1 = scan.nextInt();  // between 1 and 10^7
        int c2 = scan.nextInt();  // between 1 and 10^7
        String people = scan.nextLine();
        if (people.isEmpty())
            people = scan.nextLine();
        int pupil=0;
        int adult=0;
        for(int i=0; i<people.length(); i++)
        {
            if (people.charAt(i)=='1')
                adult++;
            else
                pupil++;
        }
        new AmusementPark(adult, pupil, c1, c2);
    }
    public static void main(String[] args)
    {
        autoTest();
    }
}
/*
10 2 2
1111101111
ans 20
*/

import static java.lang.System.out;
import java.util.Scanner;

// 795A
// n people, some pupil, some adult. separate into groups. a group must have 1 adult
// if a group has x people, cost of tickets=c1+c2(x-1)^2
// find minimal price
public class AmusementPark {

    int adult;
    int pupil;
    int n;      // 1 ≤ n ≤ 200 000
    long c1;    // 1 ≤ c1, c2 ≤ 10^7
    long c2;
    long minCost=0;

    long formula(int x)
    {
        return c1+c2*(x-1)*(x-1);
    }
    long calc(int group)
    {
        if (group==1)
        {
            return formula(n);
        }
        int avg = n/group;
        int rem = n%group;
        long cost = formula(avg);
        if ( rem>0 ) {
            cost *= (group-rem);
            return cost + rem*formula(avg+1);
        }
        else
            return cost *group;
    }
    long cost(int lo, int hi, long lowCost, long hiCost)
    {
        if (lo-hi<=1 && lo-hi>=-1) {
            return lowCost;
        }
        int mid = (lo+hi)/2;
        long midCost = calc(mid);
        //out.println("first "+lo+" second "+hi+ " mid cost "+midCost+" low clost "+lowCost+" hi cost "+hiCost);
        if (midCost<lowCost)
            return cost(mid, lo, midCost, lowCost);
        else if ( midCost < hiCost )
            return cost(lo, mid, lowCost, midCost);
        else {
            //out.println("bad mid cost "+midCost+" low clost "+lowCost+" hi cost "+hiCost);
            return midCost;
        }
    }
    AmusementPark(int a, int p, int c1, int c2)
    {
        adult = a;
        pupil = p;
        n = a+p;
        this.c1 = c1;
        this.c2 = c2;
        long cost1 = calc(1);
        long cost2 = calc(a);
        if (cost1>cost2)
            out.println(cost(a, 1, cost2, cost1));
        else if (cost1<cost2)
            out.println(cost(1, a, cost1, cost2));
        else
            out.println(cost1);
    }

    static Scanner scan = new Scanner(System.in);
    static void autoTest()
    {
        int n = scan.nextInt();  // between 1 and 20000
        int c1 = scan.nextInt();  // between 1 and 10^7
        int c2 = scan.nextInt();  // between 1 and 10^7
        String people = scan.nextLine();
        if (people.isEmpty())
            people = scan.nextLine();
        int pupil=0;
        int adult=0;
        for(int i=0; i<people.length(); i++)
        {
            if (people.charAt(i)=='1')
                adult++;
            else
                pupil++;
        }
        new AmusementPark(adult, pupil, c1, c2);
    }
    public static void main(String[] args)
    {
        autoTest();
    }
}
/*
10 2 2
1111101111
ans 20
*/

import static java.lang.System.out;
import java.util.Scanner;

// 795A
// n people, some pupil, some adult. separate into groups. a group must have 1 adult
// if a group has x people, cost of tickets=c1+c2(x-1)^2
// find minimal price
public class AmusementPark {

    int adult;
    int pupil;
    int n;
    int c1;
    int c2;
    long minCost=0;

    long formula(int x)
    {
        return c1+c2*(x-1)*(x-1);
    }
    long calc(int group)
    {
        if (group==1)
        {
            return formula(n);
        }
        int avg = n/group;
        int rem = n%group;
        long cost = formula(avg);
        if ( rem>0 ) {
            cost *= (group-rem);
            return cost + rem*formula(avg+1);
        }
        else
            return cost *group;
    }
    long cost(int lo, int hi, long lowCost, long hiCost)
    {
        if (lo-hi<=1 && lo-hi>=-1) {
            return lowCost;
        }
        int mid = (lo+hi)/2;
        long midCost = calc(mid);
        //out.println("first "+lo+" second "+hi+ " mid cost "+midCost+" low clost "+lowCost+" hi cost "+hiCost);
        if (midCost<lowCost)
            return cost(mid, lo, midCost, lowCost);
        else if ( midCost < hiCost )
            return cost(lo, mid, lowCost, midCost);
        else {
            out.println("bad mid cost "+midCost+" low clost "+lowCost+" hi cost "+hiCost);
            return 0;
        }
    }
    AmusementPark(int a, int p, int c1, int c2)
    {
        adult = a;
        pupil = p;
        n = a+p;
        this.c1 = c1;
        this.c2 = c2;
        long cost1 = calc(1);
        long cost2 = calc(a);
        if (cost1>cost2)
            out.println(cost(a, 1, cost2, cost1));
        else if (cost1<cost2)
            out.println(cost(1, a, cost1, cost2));
        else
            out.println(cost1);
    }

    static Scanner scan = new Scanner(System.in);
    static void autoTest()
    {
        int n = scan.nextInt();  // between 1 and 20000
        int c1 = scan.nextInt();  // between 1 and 10^7
        int c2 = scan.nextInt();  // between 1 and 10^7
        String people = scan.nextLine();
        if (people.isEmpty())
            people = scan.nextLine();
        int pupil=0;
        int adult=0;
        for(int i=0; i<people.length(); i++)
        {
            if (people.charAt(i)=='1')
                adult++;
            else
                pupil++;
        }
        new AmusementPark(adult, pupil, c1, c2);
    }
    public static void main(String[] args)
    {
        autoTest();
    }
}

import java.util.Scanner;

public class cf774A {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int c1=in.nextInt();
		int c2=in.nextInt();
		in.nextLine();
		String str=in.nextLine();

		int n0=0;
		int n1=0;

		for(int i=0;i<str.length();i++){
			if (str.charAt(i)=='0')
				n0++;
			else
				n1++;
		}

		long min=getv(n,1,c1,c2);

		for (int i=2;i<=n1;i++){
			long temp = getv(n,i,c1,c2);
			if (temp<min)
				min=temp;
		}

		System.out.println(min);

	}

	static long getv(int n,int k,int c1,int c2){
		long temp;
		int t1=n/k;
		int t2=n%k;
		temp=c1*k+t2*c2*(t1*t1) + (k-t2)*c2*(t1-1)*(t1-1);
		return temp;
	}

}

import java.io.*;
import java.util.StringTokenizer;

/**
 * Created by gamezovladislav on 21.03.2017.
 */
public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        int n = 1;
        for (int i = 0; i < n; i++) {
            solve(in, out);
        }
        out.close();
    }

    private static void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        long c1 = in.nextLong();
        long c2 = in.nextLong();
        String s = in.next();
        int cnt1 = 0;
        int cnt0 = 0;
        for (int i = 0; i < n; i++) {
            if (s.charAt(i) == '0') cnt0++;
            else cnt1++;
        }
        long answer = c1 + c2 * (n - 1) * (n - 1);
        for (long i = 1; i <= cnt1; i++) {
            long x1 = n / i;
            long ans1 = c1 + c2 * (x1 - 1) * (x1 - 1);
            long x2 = n / i + 1;
            long ans2 = c1 + c2 * (x2 - 1) * (x2 - 1);
            ans1 *= i;
            ans2 *= (n % i);
            answer = StrictMath.min(answer, ans1+ans2);
        }
        out.print(answer);
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }

}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Created by demich on 14.03.17.
 */
public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));

        String buf = in.readLine();
        String sp[] = buf.split(" ");
        int n = Integer.parseInt(sp[0]);
        long c1 = Integer.parseInt(sp[1]), c2 = Integer.parseInt(sp[2]);
        String str = in.readLine();

        int a = 0, b = 0;
        for(char c : str.toCharArray()){
            if(c=='1') ++a; else  ++b;
        }

        long ans = Long.MAX_VALUE;

        for(int x=1;x<=n;++x){
            int cnt = n / x;
            if(n%x!=0) ++cnt;

            if(cnt>a) continue;

            int full = n % cnt;
            if(full==0) full = cnt;

            long res = full * (c1 + c2 * (x-1) * (x-1));
            res+=(cnt-full) * (c1 + c2 * (x-2) * (x-2));

            ans = Math.min(ans, res);
        }

        System.out.println(ans);
        System.out.flush();

    }
}

import java.util.HashSet;
import java.util.Scanner;

public class BUNT
{
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int c1 = scan.nextInt();
		int c2 = scan.nextInt();
		String s = scan.nextLine();
		s = scan.nextLine();
		int a = 0, b = 0;
		for (int i = 0; i < n; i++)
		{
		    if (s.charAt(i) == '1')
		    {
		        a++;
		    }
		    else
		    {
		        b++;
		    }
		}
		long ans = Long.MAX_VALUE;
		for (int cnt = 1; cnt <= a; cnt++)
		{
		    int other = b + a - cnt;
		    int kek = other / cnt;
		    long res = c1 * (long) cnt;
		    res += (cnt - 1) * (long) kek * (long) kek * (long) c2;
		    other -= (cnt - 1) * (long) kek;
		    res += other * (long) other * (long) c2;
		    ans = Math.min(ans, res);
		}
		System.out.println(ans);
	}
}

import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int c1=sc.nextInt();
        int c2=sc.nextInt();
        String s=sc.next();
        int cnt=0;
        for(int i=0; i<n;i++)
            if(s.charAt(i)=='1')
                cnt++;
        long ans=(long)1e18;
        for(int i=1;i<=cnt;i++)
        {
            int x=n/i;
            int y=n%i;
            long tempans=(c1+c2*x*x)*y;
            tempans+=(c1+c2*(x-1)*(x-1))*(i-y);
            if(tempans<ans)
                ans=tempans;
        }
        System.out.println(ans);
    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        static final int INF = (int) 1e9;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
						int c1i = in.nextInt();
						int c2i = in.nextInt();
            String s = in.next();
            int pars_i = 0;
           // int[] kpos = new int[n];

            for (int i = 0; i < n; ++i) {
                char ch = s.charAt(i);
                if (ch == '1') {
									++pars_i;
                }
            }
						long pars = pars_i;
						long kids = n-pars;
						long c1 = c1i;
						long c2 = c2i;
						long sol = c1 + c2*(n-1)*(n-1);
						for (long teams = 2; teams <= pars; ++teams) {
							long left = n-teams;
							if (left == 0) {
								sol = Math.min(sol, c1 * teams);
								continue;
							}
							long y = left/teams;
							long yplus1nums = left%teams;
							long cur = c1*teams + c2*(y*y*teams + (y+1)*(y+1)*yplus1nums);
							if (cur > 0) {
								sol = Math.min(sol, cur);
							}
						}

						/*
            int[][][][] best = new int[2][nk + 1][nv + 1][no + 1];
            for (int[][][] x : best) for (int[][] y : x) for (int[] z : y) Arrays.fill(z, INF);
            best[0][0][0][0] = 0;
            for (int k = 0; k <= nk; ++k) {
                for (int v = 0; v <= nv; ++v) {
                    for (int o = 0; o <= no; ++o) {
                        for (int hv = 0; hv < 2; ++hv) {
                            int cur = best[hv][k][v][o];
                            if (k < nk && hv == 0) {
                                best[0][k + 1][v][o] = Math.min(best[0][k + 1][v][o], cur + Math.abs(snv[kpos[k]] - v) + Math.abs(sno[kpos[k]] - o));
                            }
                            if (v < nv) {
                                best[1][k][v + 1][o] = Math.min(best[1][k][v + 1][o], cur + Math.abs(snk[vpos[v]] - k) + Math.abs(sno[vpos[v]] - o));
                            }
                            if (o < no) {
                                best[0][k][v][o + 1] = Math.min(best[0][k][v][o + 1], cur + Math.abs(snv[opos[o]] - v) + Math.abs(snk[opos[o]] - k));
                            }
                        }
                    }
                }
            }*/

            out.println(sol);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 2*1000*1000);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        static final int INF = (int) 1e9;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
						int c1i = in.nextInt();
						int c2i = in.nextInt();
            String s = in.next();
            int pars_i = 0;
           // int[] kpos = new int[n];

            for (int i = 0; i < n; ++i) {
                char ch = s.charAt(i);
                if (ch == '1') {
									++pars_i;
                }
            }
						long pars = pars_i;
						long kids = n-pars;
						long c1 = c1i;
						long c2 = c2i;
						long sol = c1 + c2*(n-1)*(n-1);
						for (long teams = 2; teams <= pars; ++teams) {
							long left = n-teams;
							if (left == 0) {

								continue;
							}
							long y = left/teams;
							long yplus1nums = teams%left;
							long cur = c1*teams + c2*(y*y*teams + (y+1)*(y+1)*yplus1nums);
							sol = Math.min(sol, cur);
						}

						/*
            int[][][][] best = new int[2][nk + 1][nv + 1][no + 1];
            for (int[][][] x : best) for (int[][] y : x) for (int[] z : y) Arrays.fill(z, INF);
            best[0][0][0][0] = 0;
            for (int k = 0; k <= nk; ++k) {
                for (int v = 0; v <= nv; ++v) {
                    for (int o = 0; o <= no; ++o) {
                        for (int hv = 0; hv < 2; ++hv) {
                            int cur = best[hv][k][v][o];
                            if (k < nk && hv == 0) {
                                best[0][k + 1][v][o] = Math.min(best[0][k + 1][v][o], cur + Math.abs(snv[kpos[k]] - v) + Math.abs(sno[kpos[k]] - o));
                            }
                            if (v < nv) {
                                best[1][k][v + 1][o] = Math.min(best[1][k][v + 1][o], cur + Math.abs(snk[vpos[v]] - k) + Math.abs(sno[vpos[v]] - o));
                            }
                            if (o < no) {
                                best[0][k][v][o + 1] = Math.min(best[0][k][v][o + 1], cur + Math.abs(snv[opos[o]] - v) + Math.abs(snk[opos[o]] - k));
                            }
                        }
                    }
                }
            }*/

            out.println(sol);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
      /*  InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);*/
        TaskC solver = new TaskC();
        solver.solve();
        //out.close();
    }

    static class TaskC {
        static final int INF = (int) 1e9;

        public void solve() {
						Scanner in = new Scanner(System.in);
            int n = in.nextInt();
						int c1i = in.nextInt();
						int c2i = in.nextInt();
            String s = in.next();
            int pars_i = 0;
           // int[] kpos = new int[n];

            for (int i = 0; i < n; ++i) {
                char ch = s.charAt(i);
                if (ch == '1') {
									++pars_i;
                }
            }
						long pars = pars_i;
						long kids = n-pars;
						long c1 = c1i;
						long c2 = c2i;
						long sol = c1 + c2*(n-1)*(n-1);
						for (long teams = 2; teams <= pars; ++teams) {
							long left = n-teams;
							if (left == 0) {
								if (sol < 0) sol = c1 * teams;
								sol = Math.min(sol, c1 * teams);
								continue;
							}
							long y = left/teams;
							long yplus1nums = left%teams;
							long cur = c1*teams + c2*(y*y*teams + (y+1)*(y+1)*yplus1nums);
							if (sol < 0) sol = cur;
							if (cur >= 0) {
								sol = Math.min(sol, cur);
							}
						}

						/*
            int[][][][] best = new int[2][nk + 1][nv + 1][no + 1];
            for (int[][][] x : best) for (int[][] y : x) for (int[] z : y) Arrays.fill(z, INF);
            best[0][0][0][0] = 0;
            for (int k = 0; k <= nk; ++k) {
                for (int v = 0; v <= nv; ++v) {
                    for (int o = 0; o <= no; ++o) {
                        for (int hv = 0; hv < 2; ++hv) {
                            int cur = best[hv][k][v][o];
                            if (k < nk && hv == 0) {
                                best[0][k + 1][v][o] = Math.min(best[0][k + 1][v][o], cur + Math.abs(snv[kpos[k]] - v) + Math.abs(sno[kpos[k]] - o));
                            }
                            if (v < nv) {
                                best[1][k][v + 1][o] = Math.min(best[1][k][v + 1][o], cur + Math.abs(snk[vpos[v]] - k) + Math.abs(sno[vpos[v]] - o));
                            }
                            if (o < no) {
                                best[0][k][v][o + 1] = Math.min(best[0][k][v][o + 1], cur + Math.abs(snv[opos[o]] - v) + Math.abs(snk[opos[o]] - k));
                            }
                        }
                    }
                }
            }*/

            System.out.println(sol);
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        static final int INF = (int) 1e9;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
						int c1i = in.nextInt();
						int c2i = in.nextInt();
            String s = in.next();
            int pars_i = 0;
           // int[] kpos = new int[n];

            for (int i = 0; i < n; ++i) {
                char ch = s.charAt(i);
                if (ch == '1') {
									++pars_i;
                }
            }
						long pars = pars_i;
						long kids = n-pars;
						long c1 = c1i;
						long c2 = c2i;
						long sol = c1 + c2*(n-1)*(n-1);
						for (long teams = 2; teams <= pars; ++teams) {
							long left = n-teams;
							if (left == 0) {
								sol = Math.min(sol, c1 * teams);
								continue;
							}
							long y = left/teams;
							long yplus1nums = teams%left;
							long cur = c1*teams + c2*(y*y*teams + (y+1)*(y+1)*yplus1nums);
							sol = Math.min(sol, cur);
						}

						/*
            int[][][][] best = new int[2][nk + 1][nv + 1][no + 1];
            for (int[][][] x : best) for (int[][] y : x) for (int[] z : y) Arrays.fill(z, INF);
            best[0][0][0][0] = 0;
            for (int k = 0; k <= nk; ++k) {
                for (int v = 0; v <= nv; ++v) {
                    for (int o = 0; o <= no; ++o) {
                        for (int hv = 0; hv < 2; ++hv) {
                            int cur = best[hv][k][v][o];
                            if (k < nk && hv == 0) {
                                best[0][k + 1][v][o] = Math.min(best[0][k + 1][v][o], cur + Math.abs(snv[kpos[k]] - v) + Math.abs(sno[kpos[k]] - o));
                            }
                            if (v < nv) {
                                best[1][k][v + 1][o] = Math.min(best[1][k][v + 1][o], cur + Math.abs(snk[vpos[v]] - k) + Math.abs(sno[vpos[v]] - o));
                            }
                            if (o < no) {
                                best[0][k][v][o + 1] = Math.min(best[0][k][v][o + 1], cur + Math.abs(snv[opos[o]] - v) + Math.abs(snk[opos[o]] - k));
                            }
                        }
                    }
                }
            }*/

            out.println(sol);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 2*1000*1000);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        static final int INF = (int) 1e9;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
						int c1i = in.nextInt();
						int c2i = in.nextInt();
            String s = in.next();
            int pars_i = 0;
           // int[] kpos = new int[n];

            for (int i = 0; i < n; ++i) {
                char ch = s.charAt(i);
                if (ch == '1') {
									++pars_i;
                }
            }
						long pars = pars_i;
						long kids = n-pars;
						long c1 = c1i;
						long c2 = c2i;
						long sol = c1 + c2*(n-1)*(n-1);
						for (long teams = 2; teams <= pars; ++teams) {
							long left = n-teams;
							if (left == 0) {

								continue;
							}
							long y = left/teams;
							long yplus1nums = teams%left;
							long cur = c1*teams + c2*(y*y*teams + (y+1)*(y+1)*yplus1nums);
							sol = Math.min(sol, cur);
						}

						/*
            int[][][][] best = new int[2][nk + 1][nv + 1][no + 1];
            for (int[][][] x : best) for (int[][] y : x) for (int[] z : y) Arrays.fill(z, INF);
            best[0][0][0][0] = 0;
            for (int k = 0; k <= nk; ++k) {
                for (int v = 0; v <= nv; ++v) {
                    for (int o = 0; o <= no; ++o) {
                        for (int hv = 0; hv < 2; ++hv) {
                            int cur = best[hv][k][v][o];
                            if (k < nk && hv == 0) {
                                best[0][k + 1][v][o] = Math.min(best[0][k + 1][v][o], cur + Math.abs(snv[kpos[k]] - v) + Math.abs(sno[kpos[k]] - o));
                            }
                            if (v < nv) {
                                best[1][k][v + 1][o] = Math.min(best[1][k][v + 1][o], cur + Math.abs(snk[vpos[v]] - k) + Math.abs(sno[vpos[v]] - o));
                            }
                            if (o < no) {
                                best[0][k][v][o + 1] = Math.min(best[0][k][v][o + 1], cur + Math.abs(snv[opos[o]] - v) + Math.abs(snk[opos[o]] - k));
                            }
                        }
                    }
                }
            }*/

            out.println(sol);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 2*1000*1000);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}

import java.util.Scanner;

public class StringTask {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int A = in.nextInt();
        int B = in.nextInt();
        String s = in.next();
        int cnt = 0;
        for (int i=0; i<n; i++)
            if (s.charAt(i) == '1')
                cnt++;
        long res = ((long)(1000))*1000*1000*1000*1000*1000;
        for (int i=1; i<=cnt; i++)
        {
            long x = (n - i) / i;
            long y = (n - 1) / i;
            long Y = (n - i) % i;
            long X = i - Y;
            long now = A * i + ((X * x * x) + (Y * y * y)) * B;
            if (res > now)
                res = now;
        }
        System.out.println(res);
    }
}

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class SuffixArray {
    private static InputStream stream;
    private static byte[] buf = new byte[1024];
    private static int curChar;
    private static int numChars;
    private static SpaceCharFilter filter;
    private static PrintWriter pw;
    private static long mod = 1000000000+7;
    private static long mod1=(long) Math.pow(2,63);
    private static void soln(){
    	long n=nextLong();
    	long c1=nextLong();
    	long c2=nextLong();
    	String s=nextLine();
    	long cnt=0;
    	long max=Long.MAX_VALUE;
    	for(int i=0;i<s.length();i++)
    		cnt+=s.charAt(i)-'0';
    	for(long i=1;i<=cnt;i++){
    		long avg=n/i;
    		long cnt1=n%i;
    		long price;
    		price=cnt1*(c1+c2*(avg)*(avg));
    		price=(i-cnt1)*(c1+c2*(avg-1)*(avg-1));
    		max=Math.min(max,price);
    		//System.out.println(max);
    	}
    	pw.println(max);
    }
   /* private static void BFS(LinkedList<Integer>[] l,int[] co,int n,int[] pa){
    	Queue<Integer> q=new LinkedList<>();
    	q.add(0);
    	pa[0]=-1;
    	int k=1;
    	co[0]=k;
    	while(!q.isEmpty()){
    		int cur=q.poll();
    		int prev=pa[cur];
    		k=1;
    		Iterator<Integer> i=l[cur].listIterator();
    		while(i.hasNext()){
    			//System.out.println((cur+1));
    			int x=i.next();
    			if(x!=prev){
    				q.add(x);
    				while(k==co[cur] || (prev!=-1 && k==co[prev]))
    					k++;
    				co[x]=k++;
    				pa[x]=cur;
    				//max=Math.max(max,k);
    			}
    		}
    	}
    	max=co[0];
    	for(int i=1;i<n;i++)
    		max=Math.max(co[i],max);
    	pw.println(max);
    	for(int i=0;i<n;i++)
    		pw.print(co[i]+" ");
    }*/
    static class Pair implements Comparable<Pair>{
    	int x,y;
    	public Pair(int a,int b){
    		x=a;
    		y=b;
    	}
		@Override
		public int compareTo(Pair arg0) {
			return (this.x-arg0.x);
		}
    }
        public static int fun(Node root,int xor){
    	Node tmp=root;
    	int temp=xor;
    	int[] arr=new int[28];
    	for(int i=0;i<=27;i++){
    		arr[i]=temp%2;
    		temp=temp/2;
    	}
    	for(int i=27;i>=0;i--){
    		int val= arr[i];
    		if(tmp.arr[1-val]!=null)
    			tmp=tmp.arr[1-val];
    		else if(tmp.arr[val]!=null)
    			tmp=tmp.arr[val];
    	}
    	return xor^(tmp.val);
    }
    public static void insert(Node root,int xor){
    	Node temp=root;
    	int tmp=xor;
    	int[] arr=new int[28];
    	for(int i=0;i<=27;i++){
    		arr[i]=tmp%2;
    		tmp=tmp/2;
    	}
    	for(int i=27;i>=0;i--){
    		int val= arr[i];
    		if(temp.arr[val]==null){
    			temp.arr[val]=new Node();
    		}
    		temp=temp.arr[val];
    	}
    	temp.val=xor;
    }
    public static class Node{
    	int val;
    	Node[] arr;
    	public Node(){
    		arr=new Node[2];
    		val=0;
    		arr[1]=null;
    		arr[0]=null;
    	}
    }
	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
	/*public static long dijsktra(LinkedList<Pair>[] l,LinkedList<Pair>[] l1,int n){
    	long ans=0;
    	PriorityQueue<Pair> q = new PriorityQueue<>();
    	int[] arr=new int[n];
    	Arrays.fill(arr,Integer.MAX_VALUE);
   	 	arr[0]=0;
   	 	q.add(new Pair(0, 0));
   	 	while(!q.isEmpty()){
   			Pair p = q.poll();
   			for(Pair x:l[p.x]){
   				if(arr[x.x]>(arr[p.x]+x.w)){
   					arr[x.x] = (arr[p.x]+x.w);
   					q.add(new Pair(x.x,arr[x.x]));
	   			}
	   		}
	   	}
   	 	boolean[] visited=new boolean[n];
	   	visited[0] = true;
	   	PriorityQueue<Integer> q1=new PriorityQueue();
		q1.add(0);
		while(!q1.isEmpty()){
		int y = q1.poll();
			for(Pair g:l1[y]){
				if(!visited[g.x]){
					ans+=Math.max(0, Math.min(arr[y]+g.w-arr[g.x],arr[g.x]+g.w-arr[y]));
					visited[g.x] = true;
					q1.add(g.x);
				}else{
					ans+=Math.max(0, Math.min(arr[y]+g.w-arr[g.x],arr[g.x]+g.w-arr[y]));
				}
			}
		}
		//System.out.println(ans);
		return ans;
   	}*/
	private static long mat_power(long[][] matrix,long n){
		long[][] temp={{1,1,1},{1,0,0},{0,0,2}};
		if(n==1)
			return 3;
		mat_power(matrix,n/2);
		matrix_multiplication(matrix,matrix);
		if(n%2!=0){
			matrix_multiplication(matrix,temp);
		}
		return (matrix[0][0]+2*matrix[0][2])%mod;
	}
	private static void matrix_multiplication(long[][] a,long[][] b){
		long[][] result=new long[3][3];
		for(int i = 0 ; i < 3 ; i ++)
	        for(int j = 0 ; j < 3 ; j++)
	            for(int k = 0 ; k < 3 ; k++)
	                result[i][j] = (result[i][j] + a[i][k]*b[k][j]) % mod;
	    for(int i = 0 ; i < 3 ; i++)
	        for(int j = 0 ; j < 3 ; j++)
	            a[i][j] = result[i][j];
	}
    private static long power(long x,long y,long mod){
    	long ans = 1;
		while(y>0){
			if(y%2==1){
			    if(ans>mod/x) return -1;
				ans*=x;
				y-=1;
			}
			else{
			    if(x>mod/x) return -1;
				x*=x;
				y/=2;
			}
		}
		return ans;
    }
    public static class Suffix implements Comparable<Suffix>{
        int index;
        int[] rank=new int[2];
        @Override
        public int compareTo(Suffix arg0){
            return (this.rank[0]==arg0.rank[0])?(this.rank[1]<arg0.rank[1]?-1:1):(this.rank[0]<arg0.rank[0]?-1:1);
        }
    }
    private static int[] buildSuffix(String s,int n){
        Suffix[] arr=new Suffix[n];
        for(int i=0;i<n;i++)
            arr[i]=new Suffix();
        for(int i=0;i<n;i++){
            arr[i].index=i;
            arr[i].rank[0]=s.charAt(i)-'a';
            arr[i].rank[1]=((i+1)<n)?(s.charAt(i+1)-'a'):-1;
        }
        Arrays.sort(arr);
        //for(int i=0;i<n;i++)
            //System.out.print(arr[i].index);
        int[] ind=new int[n];
        for(int k=4;k<2*n;k=k*2){
            int rank=0;
            int p_rank=arr[0].rank[0];
            arr[0].rank[0]=rank;
            ind[arr[0].index]=0;
            for(int i=1;i<n;i++){
                if (arr[i].rank[0] == p_rank && arr[i].rank[1] == arr[i-1].rank[1]) {
                    p_rank = arr[i].rank[0];
                    arr[i].rank[0] = rank;
                }
                else{
                    p_rank = arr[i].rank[0];
                    arr[i].rank[0] = ++rank;
                }
                ind[arr[i].index] = i;
            }
            for(int i=0;i<n;i++){
                int n_index=arr[i].index + k/2;
                arr[i].rank[1]=(n_index<n)?arr[ind[n_index]].rank[0] : -1;
            }
            Arrays.sort(arr);
        }
        int[] suffixArr=new int[n];
        for(int i=0;i<n;i++)
            suffixArr[i]=arr[i].index;
        return suffixArr;
    }
    private static long pow(long a, long b,long mod) {
        if (b == 0)
            return 1;
        long p = pow(a, b / 2,mod);
        p = (p * p)%mod;
        return (b % 2 == 0) ? p : (a * p)%mod;
    }
    private static long gcd(long x, long y) {
        if (y == 0)
            return x;
        return gcd(y, x % y);
    }

    private static long max(long a, long b) {
        if (a > b)
            return a;
        return b;
    }

    private static long min(long a, long b) {
        if (a < b)
            return a;
        return b;
    }

    public static void main(String[] args) throws Exception {
    	new Thread(null, new Runnable() {
			public void run() {
				try {
					InputReader(System.in);
			        pw = new PrintWriter(System.out);
			        soln();
			        pw.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
    }

    public static void InputReader(InputStream stream1) {
        stream = stream1;
    }

    private static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private static boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    private static int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    private static int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    private static long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    private static String nextToken() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    private static String nextLine() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    private static int[] nextIntArray(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }
        return arr;
    }

    private static long[] nextLongArray(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextLong();
        }
        return arr;
    }

    private static void pArray(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        return;
    }

    private static void pArray(long[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        return;
    }

    private static boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }

    private interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class SuffixArray {
    private static InputStream stream;
    private static byte[] buf = new byte[1024];
    private static int curChar;
    private static int numChars;
    private static SpaceCharFilter filter;
    private static PrintWriter pw;
    private static long mod = 1000000000+7;
    private static long mod1=(long) Math.pow(2,63);
    private static void soln(){
    	long n=nextLong();
    	long c1=nextLong();
    	long c2=nextLong();
    	String s=nextLine();
    	long cnt=0;
    	long max=Long.MAX_VALUE;
    	for(int i=0;i<s.length();i++)
    		cnt+=s.charAt(i)-'0';
    	for(long i=1;i<=cnt;i++){
    		long avg=n/i;
    		long cnt1=n%i;
    		long price;
    		if(cnt1!=0){
    			price=i*(c1+c2*(avg)*(avg));
    			cnt1--;
    		}else
    			price=i*(c1+c2*(avg-1)*(avg-1));
    		max=Math.min(max,price);
    		//System.out.println(max);
    	}
    	pw.println(max);
    }
   /* private static void BFS(LinkedList<Integer>[] l,int[] co,int n,int[] pa){
    	Queue<Integer> q=new LinkedList<>();
    	q.add(0);
    	pa[0]=-1;
    	int k=1;
    	co[0]=k;
    	while(!q.isEmpty()){
    		int cur=q.poll();
    		int prev=pa[cur];
    		k=1;
    		Iterator<Integer> i=l[cur].listIterator();
    		while(i.hasNext()){
    			//System.out.println((cur+1));
    			int x=i.next();
    			if(x!=prev){
    				q.add(x);
    				while(k==co[cur] || (prev!=-1 && k==co[prev]))
    					k++;
    				co[x]=k++;
    				pa[x]=cur;
    				//max=Math.max(max,k);
    			}
    		}
    	}
    	max=co[0];
    	for(int i=1;i<n;i++)
    		max=Math.max(co[i],max);
    	pw.println(max);
    	for(int i=0;i<n;i++)
    		pw.print(co[i]+" ");
    }*/
    static class Pair implements Comparable<Pair>{
    	int x,y;
    	public Pair(int a,int b){
    		x=a;
    		y=b;
    	}
		@Override
		public int compareTo(Pair arg0) {
			return (this.x-arg0.x);
		}
    }
        public static int fun(Node root,int xor){
    	Node tmp=root;
    	int temp=xor;
    	int[] arr=new int[28];
    	for(int i=0;i<=27;i++){
    		arr[i]=temp%2;
    		temp=temp/2;
    	}
    	for(int i=27;i>=0;i--){
    		int val= arr[i];
    		if(tmp.arr[1-val]!=null)
    			tmp=tmp.arr[1-val];
    		else if(tmp.arr[val]!=null)
    			tmp=tmp.arr[val];
    	}
    	return xor^(tmp.val);
    }
    public static void insert(Node root,int xor){
    	Node temp=root;
    	int tmp=xor;
    	int[] arr=new int[28];
    	for(int i=0;i<=27;i++){
    		arr[i]=tmp%2;
    		tmp=tmp/2;
    	}
    	for(int i=27;i>=0;i--){
    		int val= arr[i];
    		if(temp.arr[val]==null){
    			temp.arr[val]=new Node();
    		}
    		temp=temp.arr[val];
    	}
    	temp.val=xor;
    }
    public static class Node{
    	int val;
    	Node[] arr;
    	public Node(){
    		arr=new Node[2];
    		val=0;
    		arr[1]=null;
    		arr[0]=null;
    	}
    }
	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
	/*public static long dijsktra(LinkedList<Pair>[] l,LinkedList<Pair>[] l1,int n){
    	long ans=0;
    	PriorityQueue<Pair> q = new PriorityQueue<>();
    	int[] arr=new int[n];
    	Arrays.fill(arr,Integer.MAX_VALUE);
   	 	arr[0]=0;
   	 	q.add(new Pair(0, 0));
   	 	while(!q.isEmpty()){
   			Pair p = q.poll();
   			for(Pair x:l[p.x]){
   				if(arr[x.x]>(arr[p.x]+x.w)){
   					arr[x.x] = (arr[p.x]+x.w);
   					q.add(new Pair(x.x,arr[x.x]));
	   			}
	   		}
	   	}
   	 	boolean[] visited=new boolean[n];
	   	visited[0] = true;
	   	PriorityQueue<Integer> q1=new PriorityQueue();
		q1.add(0);
		while(!q1.isEmpty()){
		int y = q1.poll();
			for(Pair g:l1[y]){
				if(!visited[g.x]){
					ans+=Math.max(0, Math.min(arr[y]+g.w-arr[g.x],arr[g.x]+g.w-arr[y]));
					visited[g.x] = true;
					q1.add(g.x);
				}else{
					ans+=Math.max(0, Math.min(arr[y]+g.w-arr[g.x],arr[g.x]+g.w-arr[y]));
				}
			}
		}
		//System.out.println(ans);
		return ans;
   	}*/
	private static long mat_power(long[][] matrix,long n){
		long[][] temp={{1,1,1},{1,0,0},{0,0,2}};
		if(n==1)
			return 3;
		mat_power(matrix,n/2);
		matrix_multiplication(matrix,matrix);
		if(n%2!=0){
			matrix_multiplication(matrix,temp);
		}
		return (matrix[0][0]+2*matrix[0][2])%mod;
	}
	private static void matrix_multiplication(long[][] a,long[][] b){
		long[][] result=new long[3][3];
		for(int i = 0 ; i < 3 ; i ++)
	        for(int j = 0 ; j < 3 ; j++)
	            for(int k = 0 ; k < 3 ; k++)
	                result[i][j] = (result[i][j] + a[i][k]*b[k][j]) % mod;
	    for(int i = 0 ; i < 3 ; i++)
	        for(int j = 0 ; j < 3 ; j++)
	            a[i][j] = result[i][j];
	}
    private static long power(long x,long y,long mod){
    	long ans = 1;
		while(y>0){
			if(y%2==1){
			    if(ans>mod/x) return -1;
				ans*=x;
				y-=1;
			}
			else{
			    if(x>mod/x) return -1;
				x*=x;
				y/=2;
			}
		}
		return ans;
    }
    public static class Suffix implements Comparable<Suffix>{
        int index;
        int[] rank=new int[2];
        @Override
        public int compareTo(Suffix arg0){
            return (this.rank[0]==arg0.rank[0])?(this.rank[1]<arg0.rank[1]?-1:1):(this.rank[0]<arg0.rank[0]?-1:1);
        }
    }
    private static int[] buildSuffix(String s,int n){
        Suffix[] arr=new Suffix[n];
        for(int i=0;i<n;i++)
            arr[i]=new Suffix();
        for(int i=0;i<n;i++){
            arr[i].index=i;
            arr[i].rank[0]=s.charAt(i)-'a';
            arr[i].rank[1]=((i+1)<n)?(s.charAt(i+1)-'a'):-1;
        }
        Arrays.sort(arr);
        //for(int i=0;i<n;i++)
            //System.out.print(arr[i].index);
        int[] ind=new int[n];
        for(int k=4;k<2*n;k=k*2){
            int rank=0;
            int p_rank=arr[0].rank[0];
            arr[0].rank[0]=rank;
            ind[arr[0].index]=0;
            for(int i=1;i<n;i++){
                if (arr[i].rank[0] == p_rank && arr[i].rank[1] == arr[i-1].rank[1]) {
                    p_rank = arr[i].rank[0];
                    arr[i].rank[0] = rank;
                }
                else{
                    p_rank = arr[i].rank[0];
                    arr[i].rank[0] = ++rank;
                }
                ind[arr[i].index] = i;
            }
            for(int i=0;i<n;i++){
                int n_index=arr[i].index + k/2;
                arr[i].rank[1]=(n_index<n)?arr[ind[n_index]].rank[0] : -1;
            }
            Arrays.sort(arr);
        }
        int[] suffixArr=new int[n];
        for(int i=0;i<n;i++)
            suffixArr[i]=arr[i].index;
        return suffixArr;
    }
    private static long pow(long a, long b,long mod) {
        if (b == 0)
            return 1;
        long p = pow(a, b / 2,mod);
        p = (p * p)%mod;
        return (b % 2 == 0) ? p : (a * p)%mod;
    }
    private static long gcd(long x, long y) {
        if (y == 0)
            return x;
        return gcd(y, x % y);
    }

    private static long max(long a, long b) {
        if (a > b)
            return a;
        return b;
    }

    private static long min(long a, long b) {
        if (a < b)
            return a;
        return b;
    }

    public static void main(String[] args) throws Exception {
    	new Thread(null, new Runnable() {
			public void run() {
				try {
					InputReader(System.in);
			        pw = new PrintWriter(System.out);
			        soln();
			        pw.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
    }

    public static void InputReader(InputStream stream1) {
        stream = stream1;
    }

    private static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private static boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    private static int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    private static int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    private static long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    private static String nextToken() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    private static String nextLine() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    private static int[] nextIntArray(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }
        return arr;
    }

    private static long[] nextLongArray(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextLong();
        }
        return arr;
    }

    private static void pArray(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        return;
    }

    private static void pArray(long[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        return;
    }

    private static boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }

    private interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class SuffixArray {
    private static InputStream stream;
    private static byte[] buf = new byte[1024];
    private static int curChar;
    private static int numChars;
    private static SpaceCharFilter filter;
    private static PrintWriter pw;
    private static long mod = 1000000000+7;
    private static long mod1=(long) Math.pow(2,63);
    private static void soln(){
    	long n=nextLong();
    	long c1=nextLong();
    	long c2=nextLong();
    	String s=nextLine();
    	long cnt=0;
    	long max=Long.MAX_VALUE;
    	for(int i=0;i<s.length();i++)
    		cnt+=s.charAt(i)-'0';
    	for(long i=1;i<=cnt;i++){
    		long avg=n/i;
    		long price=i*(c1+c2*(avg-1)*(avg-1));
    		if(n%i!=0)
    			price+=(c1+c2*(n%i-1)*(n%i-1));
    		max=Math.min(max,price);
    		//System.out.println(max);
    	}
    	pw.println(max);
    }
   /* private static void BFS(LinkedList<Integer>[] l,int[] co,int n,int[] pa){
    	Queue<Integer> q=new LinkedList<>();
    	q.add(0);
    	pa[0]=-1;
    	int k=1;
    	co[0]=k;
    	while(!q.isEmpty()){
    		int cur=q.poll();
    		int prev=pa[cur];
    		k=1;
    		Iterator<Integer> i=l[cur].listIterator();
    		while(i.hasNext()){
    			//System.out.println((cur+1));
    			int x=i.next();
    			if(x!=prev){
    				q.add(x);
    				while(k==co[cur] || (prev!=-1 && k==co[prev]))
    					k++;
    				co[x]=k++;
    				pa[x]=cur;
    				//max=Math.max(max,k);
    			}
    		}
    	}
    	max=co[0];
    	for(int i=1;i<n;i++)
    		max=Math.max(co[i],max);
    	pw.println(max);
    	for(int i=0;i<n;i++)
    		pw.print(co[i]+" ");
    }*/
    static class Pair implements Comparable<Pair>{
    	int x,y;
    	public Pair(int a,int b){
    		x=a;
    		y=b;
    	}
		@Override
		public int compareTo(Pair arg0) {
			return (this.x-arg0.x);
		}
    }
        public static int fun(Node root,int xor){
    	Node tmp=root;
    	int temp=xor;
    	int[] arr=new int[28];
    	for(int i=0;i<=27;i++){
    		arr[i]=temp%2;
    		temp=temp/2;
    	}
    	for(int i=27;i>=0;i--){
    		int val= arr[i];
    		if(tmp.arr[1-val]!=null)
    			tmp=tmp.arr[1-val];
    		else if(tmp.arr[val]!=null)
    			tmp=tmp.arr[val];
    	}
    	return xor^(tmp.val);
    }
    public static void insert(Node root,int xor){
    	Node temp=root;
    	int tmp=xor;
    	int[] arr=new int[28];
    	for(int i=0;i<=27;i++){
    		arr[i]=tmp%2;
    		tmp=tmp/2;
    	}
    	for(int i=27;i>=0;i--){
    		int val= arr[i];
    		if(temp.arr[val]==null){
    			temp.arr[val]=new Node();
    		}
    		temp=temp.arr[val];
    	}
    	temp.val=xor;
    }
    public static class Node{
    	int val;
    	Node[] arr;
    	public Node(){
    		arr=new Node[2];
    		val=0;
    		arr[1]=null;
    		arr[0]=null;
    	}
    }
	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;
		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}
	/*public static long dijsktra(LinkedList<Pair>[] l,LinkedList<Pair>[] l1,int n){
    	long ans=0;
    	PriorityQueue<Pair> q = new PriorityQueue<>();
    	int[] arr=new int[n];
    	Arrays.fill(arr,Integer.MAX_VALUE);
   	 	arr[0]=0;
   	 	q.add(new Pair(0, 0));
   	 	while(!q.isEmpty()){
   			Pair p = q.poll();
   			for(Pair x:l[p.x]){
   				if(arr[x.x]>(arr[p.x]+x.w)){
   					arr[x.x] = (arr[p.x]+x.w);
   					q.add(new Pair(x.x,arr[x.x]));
	   			}
	   		}
	   	}
   	 	boolean[] visited=new boolean[n];
	   	visited[0] = true;
	   	PriorityQueue<Integer> q1=new PriorityQueue();
		q1.add(0);
		while(!q1.isEmpty()){
		int y = q1.poll();
			for(Pair g:l1[y]){
				if(!visited[g.x]){
					ans+=Math.max(0, Math.min(arr[y]+g.w-arr[g.x],arr[g.x]+g.w-arr[y]));
					visited[g.x] = true;
					q1.add(g.x);
				}else{
					ans+=Math.max(0, Math.min(arr[y]+g.w-arr[g.x],arr[g.x]+g.w-arr[y]));
				}
			}
		}
		//System.out.println(ans);
		return ans;
   	}*/
	private static long mat_power(long[][] matrix,long n){
		long[][] temp={{1,1,1},{1,0,0},{0,0,2}};
		if(n==1)
			return 3;
		mat_power(matrix,n/2);
		matrix_multiplication(matrix,matrix);
		if(n%2!=0){
			matrix_multiplication(matrix,temp);
		}
		return (matrix[0][0]+2*matrix[0][2])%mod;
	}
	private static void matrix_multiplication(long[][] a,long[][] b){
		long[][] result=new long[3][3];
		for(int i = 0 ; i < 3 ; i ++)
	        for(int j = 0 ; j < 3 ; j++)
	            for(int k = 0 ; k < 3 ; k++)
	                result[i][j] = (result[i][j] + a[i][k]*b[k][j]) % mod;
	    for(int i = 0 ; i < 3 ; i++)
	        for(int j = 0 ; j < 3 ; j++)
	            a[i][j] = result[i][j];
	}
    private static long power(long x,long y,long mod){
    	long ans = 1;
		while(y>0){
			if(y%2==1){
			    if(ans>mod/x) return -1;
				ans*=x;
				y-=1;
			}
			else{
			    if(x>mod/x) return -1;
				x*=x;
				y/=2;
			}
		}
		return ans;
    }
    public static class Suffix implements Comparable<Suffix>{
        int index;
        int[] rank=new int[2];
        @Override
        public int compareTo(Suffix arg0){
            return (this.rank[0]==arg0.rank[0])?(this.rank[1]<arg0.rank[1]?-1:1):(this.rank[0]<arg0.rank[0]?-1:1);
        }
    }
    private static int[] buildSuffix(String s,int n){
        Suffix[] arr=new Suffix[n];
        for(int i=0;i<n;i++)
            arr[i]=new Suffix();
        for(int i=0;i<n;i++){
            arr[i].index=i;
            arr[i].rank[0]=s.charAt(i)-'a';
            arr[i].rank[1]=((i+1)<n)?(s.charAt(i+1)-'a'):-1;
        }
        Arrays.sort(arr);
        //for(int i=0;i<n;i++)
            //System.out.print(arr[i].index);
        int[] ind=new int[n];
        for(int k=4;k<2*n;k=k*2){
            int rank=0;
            int p_rank=arr[0].rank[0];
            arr[0].rank[0]=rank;
            ind[arr[0].index]=0;
            for(int i=1;i<n;i++){
                if (arr[i].rank[0] == p_rank && arr[i].rank[1] == arr[i-1].rank[1]) {
                    p_rank = arr[i].rank[0];
                    arr[i].rank[0] = rank;
                }
                else{
                    p_rank = arr[i].rank[0];
                    arr[i].rank[0] = ++rank;
                }
                ind[arr[i].index] = i;
            }
            for(int i=0;i<n;i++){
                int n_index=arr[i].index + k/2;
                arr[i].rank[1]=(n_index<n)?arr[ind[n_index]].rank[0] : -1;
            }
            Arrays.sort(arr);
        }
        int[] suffixArr=new int[n];
        for(int i=0;i<n;i++)
            suffixArr[i]=arr[i].index;
        return suffixArr;
    }
    private static long pow(long a, long b,long mod) {
        if (b == 0)
            return 1;
        long p = pow(a, b / 2,mod);
        p = (p * p)%mod;
        return (b % 2 == 0) ? p : (a * p)%mod;
    }
    private static long gcd(long x, long y) {
        if (y == 0)
            return x;
        return gcd(y, x % y);
    }

    private static long max(long a, long b) {
        if (a > b)
            return a;
        return b;
    }

    private static long min(long a, long b) {
        if (a < b)
            return a;
        return b;
    }

    public static void main(String[] args) throws Exception {
    	new Thread(null, new Runnable() {
			public void run() {
				try {
					InputReader(System.in);
			        pw = new PrintWriter(System.out);
			        soln();
			        pw.close();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		}, "1", 1 << 26).start();
    }

    public static void InputReader(InputStream stream1) {
        stream = stream1;
    }

    private static boolean isWhitespace(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private static boolean isEndOfLine(int c) {
        return c == '\n' || c == '\r' || c == -1;
    }

    private static int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    private static int nextInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    private static long nextLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    private static String nextToken() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));
        return res.toString();
    }

    private static String nextLine() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isEndOfLine(c));
        return res.toString();
    }

    private static int[] nextIntArray(int n) {
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }
        return arr;
    }

    private static long[] nextLongArray(int n) {
        long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextLong();
        }
        return arr;
    }

    private static void pArray(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        return;
    }

    private static void pArray(long[] arr) {
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
        System.out.println();
        return;
    }

    private static boolean isSpaceChar(int c) {
        if (filter != null)
            return filter.isSpaceChar(c);
        return isWhitespace(c);
    }

    private interface SpaceCharFilter {
        public boolean isSpaceChar(int ch);
    }
}

import java.util.*;

public class A{
    public static void main(String[] argc){

      String s;
      int n, c1, c2, oldman=0, i, ans, a1, b1, q;

      Scanner sc = new Scanner(System.in);
      n = sc.nextInt(); c1 = sc.nextInt(); c2 = sc.nextInt();
      s = sc.next();
      for (i = 0; i < n; i++) if (s.charAt(i) == '1') oldman++;
        ans = 100000000;
        for (i = 1; i <= oldman; i++) {
	   q=n-i; a1 = Integer.valueOf(q/i); b1 = n % i;
	   q = c1 * i + c2 * (a1 * a1 * i + b1 * ((a1+1) * (a1+1) - a1 * a1));
           if (q<ans) ans=q;
        }
        System.out.println(ans);
    }
}

import java.util.*;

public class A{
    public static void main(String[] argc){

      String s;
      int n, c1, c2, oldman=0, i, a1, b1, q;
      long ans = Long.MAX_VALUE;;

      Scanner sc = new Scanner(System.in);
      n = sc.nextInt(); c1 = sc.nextInt(); c2 = sc.nextInt();
      s = sc.next();
      for (i = 0; i < n; i++) if (s.charAt(i) == '1') oldman++;
        for (i = 1; i <= oldman; i++) {
	   q=n-i; a1 = Integer.valueOf(q/i); b1 = n % i;
	   q = c1 * i + c2 * (a1 * a1 * i + b1 * ((a1+1) * (a1+1) - a1 * a1));
           if (q<ans) ans=q;
        }
        System.out.println(ans);
    }
}