#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template <std::uint_fast64_t Modulus>
class modint {
	using u32 = std::uint_fast32_t;
	using u64 = std::uint_fast64_t;
	using i64 = std::int_fast64_t;
	
	public:
	u64 a;

	constexpr modint() noexcept : a(0) {}
	constexpr modint(const u64 & x) noexcept : a(x % Modulus) {}

	constexpr u64 &value() noexcept { return a; }
	constexpr const u64 &value() const noexcept { return a; }

	const modint inverse() const {
		i64 x = a, b = Modulus, u = 1, v = 0;
		while(b > 0) {
			auto t = x / b;

			std::swap(x -= t * b, b);
			std::swap(u -= t * v, v);
		}
		return modint(u);
	}
	const modint pow(i64 k) const {
		return modint(*this) ^ k;
	}

	static u64 mod() { return Modulus; }

	constexpr modint & operator+=(const modint & rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) a -= Modulus;
		return *this;
	}
	constexpr modint & operator-=(const modint & rhs) noexcept {
		if (a < rhs.a) a += Modulus;
		a -= rhs.a;
		return *this;
	}
	constexpr modint & operator*=(const modint & rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint & operator/=(modint rhs) noexcept {
		u64 exp = Modulus - 2;
		while (exp) {
			if (exp % 2) (*this) *= rhs;
			
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
	constexpr modint & operator^=(u64 k) noexcept {
		auto b = modint(1);
		while(k) {
			if(k & 1) b = b * (*this);
			(*this) *= (*this);
			k >>= 1;
		}
		return (*this) = b;
	}
	constexpr modint & operator=(const modint & rhs) noexcept {
		a = rhs.a;
		return (*this);
	}
	constexpr modint operator+(const modint & rhs) const noexcept { return modint(*this) += rhs; }
	constexpr modint operator-(const modint & rhs) const noexcept { return modint(*this) -= rhs; }	
	constexpr modint operator*(const modint & rhs) const noexcept { return modint(*this) *= rhs; }
	constexpr modint operator/(const modint & rhs) const noexcept { return modint(*this) /= rhs; }
	constexpr modint operator^(const u64 & k) const noexcept { return modint(*this) ^= k; }
	constexpr modint operator-() const noexcept { return modint(Modulus - a); }
	constexpr modint operator++() noexcept { return (*this) = modint(*this) + 1; }
	constexpr modint operator--() noexcept { return (*this) = modint(*this) - 1; }
	const bool operator==(const modint & rhs) const noexcept { return a == rhs.a; };
	const bool operator!=(const modint & rhs) const noexcept { return a != rhs.a; };
	const bool operator<=(const modint & rhs) const noexcept { return a <= rhs.a; };
	const bool operator>=(const modint & rhs) const noexcept { return a >= rhs.a; };
	const bool operator<(const modint & rhs) const noexcept { return a < rhs.a; };
	const bool operator>(const modint & rhs) const noexcept { return a > rhs.a; };
	explicit operator bool() const { return a; }
	explicit operator u32() const { return a; }

	friend std::ostream & operator<<(std::ostream & os, const modint & p) {
		return os << p.a;
	}
	friend std::istream & operator>>(std::istream & is, modint & p) {
		u64 t;
		is >> t;
		p = modint(t);
		return is;
	}
};

using mint = modint<998244353>;

int main() {
	int n; scanf("%d", &n);
	std::string s; cin >> s;

	std::vector<int> vec;
	for(i64 i = 1; i * i <= n; i++) {
		if(n % i) continue;
		if((n / i) % 2) vec.push_back(i);
		if(i % 2) vec.push_back(n / i);
	}
	sort(begin(vec), end(vec));

	std::vector<mint> latte(n + 1, 1);
	for(int i = 0; i < n; i++) latte[i + 1] = latte[i] * 2;
	
	auto tan = [](std::string s) {
		for(auto & c: s) {
			if(c == '0') c = '1';
			else c = '0';
		}
		return s;
	};
	
	mint ans = 0, tmp = 0;
	std::vector<mint> degwer(n + 1, 0);
	for(int i = 0; i < s.size(); i++) tmp = tmp * 2 + (s[i] - '0'); tmp += 1;
	for(auto k: vec) {
		if(k == n) continue;

		bool f = false;
		std::string t = s.substr(0, k);
		for(int i = 1; i * k < n; i++) {
			if(i & 1) {
				if(tan(t) == s.substr(i * k, k)) continue;
				if(tan(t) > s.substr(i * k, k)) {
					f = true;
				}
				break;
			} else {
				if(t == s.substr(i * k, k)) continue;
				if(t > s.substr(i * k, k)) {
					f = true;
				}
				break;
			}
		}
		
		mint malta = 0;
		for(int i = 0; i < t.size(); i++) malta = malta * 2 + (t[i] - '0');
		malta += (f ? 0 : 1);
		malta += degwer[k];
		
		for(int i = k; i < n + 1; i += k) degwer[i] -= malta;

		ans += malta * 2 * k;
		tmp -= malta;
	}
	ans += tmp * (2 * n);


	printf("%lld\n", ans.value());
	return 0;
}


Measured memory_bytes: 3716