#include <bits/stdc++.h>
using namespace std;
unsigned long long int w, v, qt = 0, n;
inline unsigned long long int f(unsigned long long int x) {
  return w * (1 - x) * (1 - x) + v;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> v >> w;
  char c;
  while (cin >> c) qt += c == '1';
  unsigned long long int ans = (~0ULL);
  for (int i = 1; i <= qt; i++) {
    unsigned long long int tmp = 0;
    tmp += (i - (n % i)) * f(n / i);
    tmp += (n % i) * f(n / i + 1);
    ans = min(ans, tmp);
  }
  cout << ans << endl;
  return 0;
}
