#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cassert>
#include <random>
#include <chrono>

/* #include <atcoder/all> */
/* using namespace atcoder; */
using namespace std;

void debug_out(){ cout << "\n"; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const ll MOD = 1000000007;
/* const ll MOD = 998244353; */
const ll INF = 1ll<<60;
const double PI = acos(-1);

struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N;
  cin >> N;

  N *= 2;

  int ans = 0;
  vector<int> v;
  for(int i = 1; i*i <= N; i++){
    if(N%i == 0){
      if(i*i != N) v.emplace_back(N/i);
      v.emplace_back(i);
    }
  }
  N /= 2;

  for(auto x : v){
    if((x+1)%2 == 0){
      if(N%x == 0) ans++;
    }else{
      if((N+x/2)%x == 0) ans++;
      /* cout << N << " " << x/2 << "  " << N+x/2 << " " << x << "\n"; */
    }
  }


  cout << ans << "\n";

  return 0;
}

#include <stdio.h>
#include <algorithm>
#include <vector>

using namespace std;


typedef long long ll;
ll n, f[200111];

ll ck[200111], step[200111];
ll dfs(ll x, ll color, ll curstep = 1) {
	ck[x] = color;
	step[x] = curstep;

	ll nx = f[x];
	if (ck[nx] == 0) {
		return dfs(nx, color, curstep + 1);
	}
	if (ck[nx] == color) {
		return curstep + 1 - step[nx];
	}
	return 0;
}

int main(void) {
	scanf("%lld", &n);
	for (ll i = 1; i <= n; i++) {
		scanf("%lld", &f[i]);
	}

	ll t = 0;
	for (ll i = 1; i <= n; i++) {
		if (!ck[i]) {
			ll cycle = dfs(i, i);
			if (cycle) {
				t++;
			}
		}
	}

	ll p = 998244353;
	ll ans = 1;
	for (ll i = 0; i < t; i++) {
		ans *= 2;
		ans %= p;
	}

	printf("%lld\n", ans - 1);
}