func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 200010;   const long long mod = 1000000007ll;   int n, cnt;   long long ans = 1;   int to[N], vis[N], dep[N];   long long power(long long x, long long t) {     long long ret = 1;     for (; t; t >>= 1ll, x = x * x % mod)       if (t & 1ll) ret = ret * x % mod;     return ret;   }   void dfs(int u, int step, int d) {     vis[u] = d;     dep[u] = step;     if (!vis[to[u]])       dfs(to[u], step + 1, d);     else if (vis[to[u]] == vis[u]) {       ans = ans * (power(2, dep[u] - dep[to[u]] + 1) - 2) % mod;       cnt += dep[u] - dep[to[u]] + 1;     }   }   int main() {     scanf( %d , &n);     for (int i = 1; i <= n; ++i) scanf( %d , &to[i]);     for (int i = 1; i <= n; ++i)       if (!vis[i]) dfs(i, 0, i);     ans = ans * power(2, n - cnt) % mod;     printf( %lld n , ans);     return 0;   }   