#include <bits/stdc++.h>
using namespace std;
int main() {
  char s;
  long long n, k = 0, m, l, min = -1, x, c1, c2;
  cin >> n >> c1 >> c2;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == '1') k++;
  }
  for (int i = 1; i <= k; i++) {
    m = n / i;
    l = n % i;
    x = l * (c1 + c2 * m * m) + (i - l) * (c1 + c2 * (m - 1) * (m - 1));
    if (x < min || min == -1) min = x;
  }
  cout << min;
}
