#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define DEBUG(x) { cout << #x << " = "; cout << (x) << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }

#define sqr(x) ((x) * (x))
using namespace std;

const int MN = 100111;
const long long MOD = 1000000007;

vector<int> ke[MN];
long long f[2][MN];

void dfs(int u) {
    f[0][u] = 0;
    f[1][u] = 1;
    for(int v : ke[u]) {
        dfs(v);

        long long f0 = (f[0][u] * (f[0][v] + 1) + f[1][u] * f[1][v]) % MOD;
        long long f1 = (f[0][u] * f[1][v] + f[1][u] * (f[0][v] + 1)) % MOD;

        f[0][u] = f0;
        f[1][u] = f1;
    }
    f[0][u] = (2 * f[0][u]) % MOD;
    f[1][u] = (2 * f[1][u]) % MOD;

    long long t[2];
    // Odd child, each: odd --> subtract from f[0][u]
    t[0] = 1; t[1] = 0;
    for(int v : ke[u]) {
        long long t0 = (t[0] + t[1] * f[1][v]) % MOD;
        long long t1 = (t[1] + t[0] * f[1][v]) % MOD;

        t[0] = t0;
        t[1] = t1;
    }
    f[0][u] = (f[0][u] - t[1] + MOD) % MOD;

    // Even child, each: even --> subtract from f[1][u]
    // Odd child, each: even --> subtract from f[1][u]
    t[0] = 1; t[1] = 0;
    for(int v : ke[u]) {
        long long t0 = (t[0] + t[1] * f[0][v]) % MOD;
        long long t1 = (t[1] + t[0] * f[0][v]) % MOD;

        t[0] = t0;
        t[1] = t1;
    }
    f[1][u] = (f[1][u] - t[0] - t[1] + MOD + MOD) % MOD;
}

int main() {
    ios :: sync_with_stdio(false);
    cout << (fixed) << setprecision(9);
    int n;
    while (cin >> n) {
        FOR(i,1,n) ke[i].clear();
        FOR(i,2,n) {
            int fi; cin >> fi;
            ke[fi].push_back(i);
        }
        dfs(1);
//        PR(f[0], n);
//        PR(f[1], n);

        cout << (f[0][1] + f[1][1]) % MOD << endl;
    }
    return 0;
}


#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <complex>
#include <iostream>
#include <algorithm>

#include <ctime>
#include <deque>
#include <bitset>
#include <cctype>
#include <utility>
#include <cassert>
using namespace std;

#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define DEBUG(x) { cout << #x << " = " << x << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }

const long long MOD = 1000000007LL;
const int MN = 100111;

int n;
vector<int> ke[MN];
long long f[MN][2][2];

void update(long long &x, long long val) {
    x = (x + val) % MOD;
}

long long power(long long x, long long k) {
    if (k == 0) return 1;
    if (k == 1) return x % MOD;
    long long mid = power(x, k >> 1);
    mid = (mid * mid) % MOD;

    if (k & 1) return mid * x % MOD;
    else return mid;
}

void dfs(int u) {
    vector< long long > g[2][2];

    int nChild = ke[u].size();
    REP(turn,2) REP(x,2) g[x][turn].resize(nChild+1);

    REP(x,2) REP(y,2) f[u][x][y] = 0;

    REP(turn,2)
    REP(t,2) {
        // So we go in with color t
        // then immediately count = count + 1
        REP(i,nChild+1) REP(x,2) g[0][x][i] = g[1][x][i] = 0;
        g[1-t][0][0] = 1;
        g[t][0][0] = 0;

        REP(i,nChild) REP(x,2) {
            int v = ke[u][i];
            dfs(v);

            // If not visit v
            update(g[0][x][i+1], g[0][x][i]);
            update(g[1][x][i+1], g[1][x][i]);

            // If visit v
            update(g[0][1-x][i+1], g[0][x][i] * f[v][0][0] + g[1][x][i] * f[v][1][0]);
            update(g[1][1-x][i+1], g[0][x][i] * f[v][0][1] + g[1][x][i] * f[v][1][1]);
        }

        // if (turn == 0) {
        update(f[u][t][t], g[t][1][nChild]);
        update(f[u][t][1-t], g[1-t][1][nChild]);
        // }

        if (turn == 0) {
            update(f[u][t][t], g[t][0][nChild]);
            update(f[u][t][1-t], g[1-t][0][nChild]);
        }

        reverse(ke[u].begin(), ke[u].end());
    }
}

int main() {
    ios :: sync_with_stdio(false); cin.tie(NULL);
    cout << (fixed) << setprecision(6);
    while (cin >> n) {
        FOR(i,1,n) ke[i].clear();

        FOR(v,2,n) {
            int u; cin >> u;
            ke[u].push_back(v);
        }

        dfs(1);

        // FOR(i,1,n) cout << f[i][0][0] << ' '; cout << endl;
        // FOR(i,1,n) cout << f[i][1][1] << ' '; cout << endl;
        // FOR(i,1,n) cout << f[i][0][1] << ' '; cout << endl;

        cout << (f[1][0][0] + f[1][0][1]) % MOD << endl;
    }
    return 0;
}


#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <complex>
#include <iostream>
#include <algorithm>

#include <ctime>
#include <deque>
#include <bitset>
#include <cctype>
#include <utility>
#include <cassert>
using namespace std;

#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define DEBUG(x) { cout << #x << " = " << x << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }

const long long MOD = 1000000007LL;
const int MN = 100111;

int n;
vector<int> ke[MN];
long long f[MN][2][2];

void update(long long &x, long long val) {
    x = (x + val) % MOD;
}

void dfs(int u) {
    vector< long long > g[2];

    int nChild = ke[u].size();
    REP(turn,2) g[turn].resize(nChild+1);

    REP(x,2) REP(y,2) f[u][x][y] = 0;

    REP(t,2) {
        REP(i,nChild+1) g[0][i] = g[1][i] = 0;

        // So we go in with color t
        // then immediately count = count + 1
        g[1-t][0] = 1;
        g[t][0] = 0;

        REP(i,nChild) {
            int v = ke[u][i];
            dfs(v);

            // If not visit v
            update(g[0][i+1], g[0][i]);
            update(g[1][i+1], g[1][i]);

            // If visit v
            update(g[0][i+1], g[0][i] * f[v][0][0] + g[1][i] * f[v][1][0]);
            update(g[1][i+1], g[0][i] * f[v][0][1] + g[1][i] * f[v][1][1]);
        }

        update(f[u][t][t], g[t][nChild]);
        update(f[u][t][1-t], g[1-t][nChild]);

        reverse(ke[u].begin(), ke[u].end());
    }
    long long x = f[u][0][1], y = f[u][1][0];
    if (nChild > 1) f[u][0][1] = f[u][1][0] = x + y;
    else f[u][0][1] = f[u][1][0] = x;
}

int main() {
    ios :: sync_with_stdio(false); cin.tie(NULL);
    cout << (fixed) << setprecision(6);
    while (cin >> n) {
        FOR(i,1,n) ke[i].clear();

        FOR(v,2,n) {
            int u; cin >> u;
            ke[u].push_back(v);
        }

        dfs(1);

        // FOR(i,1,n) cout << f[i][0][0] << ' '; cout << endl;
        // FOR(i,1,n) cout << f[i][1][1] << ' '; cout << endl;
        // FOR(i,1,n) cout << f[i][0][1] << ' '; cout << endl;

        cout << (f[1][0][0] + f[1][0][1] - 1 + MOD ) % MOD << endl;
    }
    return 0;
}


#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <complex>
#include <iostream>
#include <algorithm>

#include <ctime>
#include <deque>
#include <bitset>
#include <cctype>
#include <utility>
#include <cassert>
using namespace std;

#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define DEBUG(x) { cout << #x << " = " << x << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }

const long long MOD = 1000000007LL;
const int MN = 100111;

int n;
vector<int> ke[MN];
long long f[MN][2][2];

void update(long long &x, long long val) {
    x = (x + val) % MOD;
}

long long power(long long x, long long k) {
    if (k == 0) return 1;
    if (k == 1) return x % MOD;
    long long mid = power(x, k >> 1);
    mid = (mid * mid) % MOD;

    if (k & 1) return mid * x % MOD;
    else return mid;
}

void dfs(int u) {
    vector< long long > g[2][2];

    int nChild = ke[u].size();
    REP(turn,2) REP(x,2) g[x][turn].resize(nChild+1);

    REP(x,2) REP(y,2) f[u][x][y] = 0;

    REP(turn,2)
    REP(t,2) {
        // So we go in with color t
        // then immediately count = count + 1
        REP(i,nChild+1) REP(x,2) g[0][x][i] = g[1][x][i] = 0;
        g[1-t][0][0] = 1;
        g[t][0][0] = 0;

        REP(i,nChild) REP(x,2) {
            int v = ke[u][i];
            dfs(v);

            // If not visit v
            update(g[0][x][i+1], g[0][x][i]);
            update(g[1][x][i+1], g[1][x][i]);

            // If visit v
            update(g[0][1-x][i+1], g[0][x][i] * f[v][0][0] + g[1][x][i] * f[v][1][0]);
            update(g[1][1-x][i+1], g[0][x][i] * f[v][0][1] + g[1][x][i] * f[v][1][1]);
        }

        // if (turn == 0) {
        if (turn == 0) update(f[u][t][t], g[t][1][nChild]);
        update(f[u][t][1-t], g[1-t][1][nChild]);
        // }

        if (turn == 0) {
            update(f[u][t][t], g[t][0][nChild]);
            update(f[u][t][1-t], g[1-t][0][nChild]);
        }

        reverse(ke[u].begin(), ke[u].end());
    }
}

int main() {
    ios :: sync_with_stdio(false); cin.tie(NULL);
    cout << (fixed) << setprecision(6);
    while (cin >> n) {
        FOR(i,1,n) ke[i].clear();

        FOR(v,2,n) {
            int u; cin >> u;
            ke[u].push_back(v);
        }

        dfs(1);

        // FOR(i,1,n) cout << f[i][0][0] << ' '; cout << endl;
        // FOR(i,1,n) cout << f[i][1][1] << ' '; cout << endl;
        // FOR(i,1,n) cout << f[i][0][1] << ' '; cout << endl;

        cout << (f[1][0][0] + f[1][0][1]) % MOD << endl;
    }
    return 0;
}


#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <complex>
#include <iostream>
#include <algorithm>

#include <ctime>
#include <deque>
#include <bitset>
#include <cctype>
#include <utility>
#include <cassert>
using namespace std;

#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

#define DEBUG(x) { cout << #x << " = " << x << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }

const long long MOD = 1000000007LL;
const int MN = 100111;

int n;
vector<int> ke[MN];
long long f[MN][2][2];

void update(long long &x, long long val) {
    x = (x + val) % MOD;
}

long long power(long long x, long long k) {
    if (k == 0) return 1;
    if (k == 1) return x % MOD;
    long long mid = power(x, k >> 1);
    mid = (mid * mid) % MOD;

    if (k & 1) return mid * x % MOD;
    else return mid;
}

void dfs(int u) {
    vector< long long > g[2][2];

    int nChild = ke[u].size();
    REP(turn,2) REP(x,2) g[x][turn].resize(nChild+1);

    REP(x,2) REP(y,2) f[u][x][y] = 0;

    REP(turn,2)
    REP(t,2) {
        // So we go in with color t
        // then immediately count = count + 1
        REP(i,nChild+1) REP(x,2) g[0][x][i] = g[1][x][i] = 0;
        g[1-t][0][0] = 1;
        g[t][0][0] = 0;

        REP(i,nChild) REP(x,2) {
            int v = ke[u][i];
            dfs(v);

            // If not visit v
            update(g[0][x][i+1], g[0][x][i]);
            update(g[1][x][i+1], g[1][x][i]);

            // If visit v
            update(g[0][1-x][i+1], g[0][x][i] * f[v][0][0] + g[1][x][i] * f[v][1][0]);
            update(g[1][1-x][i+1], g[0][x][i] * f[v][0][1] + g[1][x][i] * f[v][1][1]);
        }

        // if (turn == 0) {
        update(f[u][t][t], g[t][1][nChild]);
        if (turn == 0) update(f[u][t][1-t], g[1-t][1][nChild]);
        // }

        if (turn == 0) {
            update(f[u][t][t], g[t][0][nChild]);
            update(f[u][t][1-t], g[1-t][0][nChild]);
        }

        reverse(ke[u].begin(), ke[u].end());
    }
}

int main() {
    ios :: sync_with_stdio(false); cin.tie(NULL);
    cout << (fixed) << setprecision(6);
    while (cin >> n) {
        FOR(i,1,n) ke[i].clear();

        FOR(v,2,n) {
            int u; cin >> u;
            ke[u].push_back(v);
        }

        dfs(1);

        // FOR(i,1,n) cout << f[i][0][0] << ' '; cout << endl;
        // FOR(i,1,n) cout << f[i][1][1] << ' '; cout << endl;
        // FOR(i,1,n) cout << f[i][0][1] << ' '; cout << endl;

        cout << (f[1][0][0] + f[1][0][1]) % MOD << endl;
    }
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>

using namespace std;

#define pb push_back
#define f first
#define s second
#define mp make_pair
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < (int) n; ++i)
#define ford(i, n) for (int i = ((int) n) - 1; i >= 0; --i)
#define y1 gftxdtrtfhyjfctrxujkvbhyjice
#define y0 ehfoiuvhefroerferjhfjkehfjke
#define left sdhfsjkshdjkfsdfgkqqweqweh
#define right yytrwtretywretwreytwreytwr
#define all(C) begin(C), end(C)

#define debug(x) cerr << #x" = " << x << '\n';

template <typename T>
inline T sqr( T x ) {
	return x * x;
}

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;
typedef vector <ll> vll;
typedef vector <int> vi;
typedef vector <vector <int> > vvi;
typedef vector <pii> vii;

const double EPS = 1e-9;
const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;

void add(int& x, int y) {
  if  ((x += y) >= MOD)
    x -= MOD;
}

int mul(int x, int y) {
  return x * 1ll * y % MOD;
}

vi g[MAXN];
int n;
int dp[MAXN][2][2];

void dfs(int v) {
  sort(g[v].begin(), g[v].end());

  for (int to : g[v]) {
    dfs(to);
  }

  forn(C1, 2) {
    forn(C2, 2) {
      int d[2][2];
      int nd[2][2];
      memset (d, 0, sizeof d);
      for (int to : g[v]) {
        memset (nd, 0, sizeof nd);

        // do not take
        forn(c1, 2) forn(c2, 2) nd[c1][c2] = d[c1][c2];

        // take and we are not first
        forn(c1, 2) forn(c2, 2) {
          add(nd[c1][c2], mul(d[c2][c1], dp[to][c1][c2]));
        }

        // we are first
        add(nd[C1][C2], dp[to][C1][C2]);

        swap(d, nd);
      }

//      forn(c1, 2) forn(c2, 2) printf("v = %d, c1 = %d, c2 = %d, d = %d\n", v, c1, c2, d[c1][c2]);
      // d[c1][c2] -- in two directions

      int d_up[2];
      int nd_up[2];
      memset (d_up, 0, sizeof d_up);
      for (int to : g[v]) {
        memset (nd_up, 0, sizeof nd_up);

        // do not take
        forn(c, 2) nd_up[c] = d_up[c];

        // take, we are not first
        forn(c1, 2) forn(c2, 2) add(nd_up[c2], mul(d_up[c1], dp[to][c1][c2]));

        // take, we are first
        forn(c2, 2) add(nd_up[c2], dp[to][C1][c2]);

        swap(d_up, nd_up);
      }

      int d_down[2];
      int nd_down[2];
      memset (d_down, 0, sizeof d_down);
      for (int i = sz(g[v]) - 1; i >= 0; --i) {
        int to = g[v][i];

        memset (nd_down, 0, sizeof nd_down);

        // do not take
        forn(c, 2) nd_down[c] = d_down[c];

        // take, we are not first
        forn(c1, 2) forn(c2, 2) add(nd_down[c2], mul(d_down[c1], dp[to][c1][c2]));

        // take, we are first
        forn(c2, 2) add(nd_down[c2], dp[to][C1][c2]);

        swap(d_down, nd_down);
      }

      dp[v][C1 ^ 1][C2] = 0;
      add(dp[v][C1 ^ 1][C2], d_up[C2]);
      add(dp[v][C1 ^ 1][C2], d_down[C2]);

      add(dp[v][C1 ^ 1][C2], - d[0][C2] + MOD);
      add(dp[v][C1 ^ 1][C2], - d[1][C2] + MOD);
    }
  }

  add(dp[v][0][1], 1);
  add(dp[v][1][0], 1);
/*
  forn(C1, 2) {
    forn(C2, 2) {
      printf("dp[%d][%d][%d] = %d\n", v, C1, C2, dp[v][C1][C2]);
    }
  }
*/
}

int main() {
  scanf("%d", &n);
  forn(i, n - 1) {
    int par;
    scanf("%d", &par);
    --par;
    g[par].pb(i + 1);
  }

  dfs(0);

  int ans = 0;
  add(ans, dp[0][0][0]);
  add(ans, dp[0][0][1]);
  printf("%d\n", ans);
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define p 1000000007
#define MAXN 100005

//subtrees of even, odd size
ll arreven[MAXN]; ll arrodd[MAXN];
ll even[MAXN], odd[MAXN], n; vector<ll> children[MAXN];
void dfs(int x) {
    if (children[x].size() == 0) {
        even[x] = 0; odd[x] = 1; return;
    } for (int i = 0; i < children[x].size(); ++i)
        dfs(children[x][i]);
    arreven[0] = 1; arrodd[0] = 0; for (int i = 0; i < children[x].size(); ++i) {
        arreven[i+1] = arreven[i]*(even[children[x][i]]+1)+arrodd[i]*odd[children[x][i]];
        arreven[i+1]%=p; arrodd[i+1] = arreven[i]*odd[children[x][i]]+arrodd[i]*(even[children[x][i]]+1);
        arrodd[i+1]%=p;
    } even[x] = 2*arrodd[children[x].size()]; odd[x] = 2*arreven[children[x].size()];
    //subtract off duplicates : all even/sum is even, and all odd/sum is odd

    ll prod = 1; for (int i = 0; i < children[x].size(); ++i)
        prod = (prod*(even[children[x][i]]+1))%p;
    odd[x] -= prod; arreven[0] = 1; arrodd[0] = 0; for (int i = 0; i < children[x].size(); ++i) {
        arreven[i+1] = arreven[i]; arrodd[i+1] = arreven[i]*odd[children[x][i]]+arrodd[i];
        arrodd[i]%=p;
    }
    even[x] -= arrodd[children[x].size()];
    return;
}

int main() {
    cin >> n; for (int i = 0; i < n-1; ++i) {
        int x; cin >> x; children[x-1].push_back(i+1);
    } for (int i = 0; i < n; ++i)
        even[i] = odd[i] = 0;
    dfs(0); cout << (odd[0]+even[0])%p << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define p 1000000007
#define MAXN 100005

//subtrees of even, odd size
ll arreven[MAXN]; ll arrodd[MAXN];
ll even[MAXN], odd[MAXN], n; vector<ll> children[MAXN];
void dfs(int x) {
    if (children[x].size() == 0) {
        even[x] = 0; odd[x] = 1; return;
    } for (int i = 0; i < children[x].size(); ++i)
        dfs(children[x][i]);
    arreven[0] = 1; arrodd[0] = 0; for (int i = 0; i < children[x].size(); ++i) {
        arreven[i+1] = arreven[i]*(even[children[x][i]]+1)+arrodd[i]*odd[children[x][i]];
        arreven[i+1]%=p; arrodd[i+1] = arreven[i]*odd[children[x][i]]+arrodd[i]*(even[children[x][i]]+1);
        arrodd[i+1]%=p;
    } even[x] = 2*arrodd[children[x].size()]; odd[x] = 2*arreven[children[x].size()];
    //subtract off duplicates : all even/sum is even, and all odd/sum is odd

    ll prod = 1; for (int i = 0; i < children[x].size(); ++i)
        prod = (prod*(even[children[x][i]]+1))%p;
    odd[x] -= prod; arreven[0] = 1; arrodd[0] = 0; for (int i = 0; i < children[x].size(); ++i) {
        arreven[i+1] = arreven[i]+arrodd[i]*odd[children[x][i]]; arrodd[i+1] = arreven[i]*odd[children[x][i]]+arrodd[i];
        arrodd[i+1]%=p; arreven[i+1]%=p;
    }
    even[x] -= arrodd[children[x].size()];
    return;
}

int main() {
    cin >> n; for (int i = 0; i < n-1; ++i) {
        int x; cin >> x; children[x-1].push_back(i+1);
    } for (int i = 0; i < n; ++i)
        even[i] = odd[i] = 0;
    dfs(0); cout << (odd[0]+even[0])%p << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define p 1000000007
#define MAXN 100005

//subtrees of even, odd size
ll arreven[MAXN]; ll arrodd[MAXN];
ll even[MAXN], odd[MAXN], n; vector<ll> children[MAXN];
void dfs(int x) {
	if (children[x].size() == 0) {
		even[x] = 0; odd[x] = 1; return;
	} for (int i = 0; i < children[x].size(); ++i)
		dfs(children[x][i]);
	arreven[0] = 1; arrodd[0] = 0; for (int i = 0; i < children[x].size(); ++i) {
		arreven[i+1] = arreven[i]*(even[children[x][i]]+1)+arrodd[i]*odd[children[x][i]];
		arreven[i+1]%=p; arrodd[i+1] = arreven[i]*odd[children[x][i]]+arrodd[i]*(even[children[x][i]]+1);
		arrodd[i+1]%=p;
	} even[x] = 2*arrodd[children[x].size()]; odd[x] = 2*arreven[children[x].size()];
	//subtract off duplicates : all even/sum is even, and all odd/sum is odd

	ll prod = 1; for (int i = 0; i < children[x].size(); ++i)
		prod = (prod*(even[children[x][i]]+1))%p;
	odd[x] -= prod; odd[x] = (odd[x]+p)%p; arreven[0] = 1; arrodd[0] = 0; for (int i = 0; i < children[x].size(); ++i) {
		arreven[i+1] = arreven[i]+arrodd[i]*odd[children[x][i]]; arrodd[i+1] = arreven[i]*odd[children[x][i]]+arrodd[i];
		arrodd[i+1]%=p; arreven[i+1]%=p;
	}
	even[x] -= arrodd[children[x].size()]; even[x] = (even[x]+p)%p;
	return;
}

int main() {
	cin >> n; for (int i = 0; i < n-1; ++i) {
		int x; cin >> x; children[x-1].push_back(i+1);
	} for (int i = 0; i < n; ++i)
		even[i] = odd[i] = 0;
	dfs(0); cout << (odd[0]+even[0])%p << endl;
}


#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int MOD = 1000000007;

int N;
vector<int> V[100002];
int D[100002][2];

void Dfs(int x)
{
    for (auto it = V[x].begin(); it != V[x].end(); ++it)
        Dfs(*it);

    int a0 = 0, a1 = 1;
    for (auto it = V[x].begin(); it != V[x].end(); ++it)
    {
        int old0 = a0, old1 = a1;

        a0 = (1LL * old0 * (D[*it][0] + 1) + 1LL * old1 * D[*it][1]) % MOD;
        a1 = (1LL * old0 * D[*it][1] + 1LL * old1 * (D[*it][0] + 1)) % MOD;
    }

    int b0 = 0, b1 = 1;
    for (auto it = V[x].rbegin(); it != V[x].rend(); ++it)
    {
        int old0 = b0, old1 = b1;

        b0 = (1LL * old0 * (D[*it][0] + 1) + 1LL * old1 * D[*it][1]) % MOD;
        b1 = (1LL * old0 * D[*it][1] + 1LL * old1 * (D[*it][0] + 1)) % MOD;
    }

    int c0 = 1, c10 = 1, c11 = 0;
    for (auto it = V[x].begin(); it != V[x].end(); ++it)
    {
        c0 = 1LL * c0 * (D[*it][0] + 1) % MOD;

        int old0 = c10, old1 = c11;
        c10 = (1LL * old0 + 1LL * D[*it][1] * old1) % MOD;
        c11 = (1LL * old1 + 1LL * D[*it][1] * old0) % MOD;
    }

    D[x][0] = (1LL * MOD + a0 + b0 - c11) % MOD;
    D[x][1] = (1LL * MOD + a1 + b1 - c0) % MOD;
}

int main()
{
    cin.sync_with_stdio(false);

    cin >> N;
    for (int i = 2, par; i <= N; ++i)
    {
        cin >> par;
        V[par].push_back(i);
    }
    for (int i = 1; i <= N; ++i)
        sort(V[i].begin(), V[i].end());

    Dfs(1);
    cout << (D[1][0] + D[1][1]) % MOD << '\n';
}


#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int MOD = 1000000007;

int N;
vector<int> V[100002];
int D[100002][2];

void Dfs(int x)
{
    for (auto it = V[x].begin(); it != V[x].end(); ++it)
        Dfs(*it);

    int a0 = 0, a1 = 1;
    for (auto it = V[x].begin(); it != V[x].end(); ++it)
    {
        int old0 = a0, old1 = a1;

        a0 = (1LL * old0 * (D[*it][0] + 1) + 1LL * old1 * D[*it][1]) % MOD;
        a1 = (1LL * old0 * D[*it][1] + 1LL * old1 * (D[*it][0] + 1)) % MOD;
    }

    int b0 = 0, b1 = 1;
    for (auto it = V[x].rbegin(); it != V[x].rend(); ++it)
    {
        int old0 = b0, old1 = b1;

        b0 = (1LL * old0 * (D[*it][0] + 1) + 1LL * old1 * D[*it][1]) % MOD;
        b1 = (1LL * old0 * D[*it][1] + 1LL * old1 * (D[*it][0] + 1)) % MOD;
    }

    int c0 = 1, c10 = 1, c11 = 0;
    for (auto it = V[x].begin(); it != V[x].end(); ++it)
    {
        c0 = 1LL * c0 * (D[*it][0] + 1) % MOD;

        int old0 = c10, old1 = c11;
        c10 = (1LL * old0 + 1LL * D[*it][1] * old1) % MOD;
        c11 = (1LL * old1 + 1LL * D[*it][1] * old0) % MOD;
    }

    D[x][0] = a0 + b0 - c11;
    D[x][1] = a1 + b1 - c0;
}

int main()
{
    cin.sync_with_stdio(false);

    cin >> N;
    for (int i = 2, par; i <= N; ++i)
    {
        cin >> par;
        V[par].push_back(i);
    }
    for (int i = 1; i <= N; ++i)
        sort(V[i].begin(), V[i].end());

    Dfs(1);
    cout << (D[1][0] + D[1][1]) % MOD << '\n';
}


#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAXN = 100010;

const int mod = 1e9 + 7;

int add(int a, int b) {
  return a+b >= mod ? a+b-mod : a+b;
}

int mul(int a, int b) {
  return (llint(a)*b)%mod;
}

int dad[MAXN];
int f[MAXN][2];
int g[MAXN][2][4];
vector<int> E[MAXN];

int main(void) {
  int n;
  scanf("%d", &n);
  FOR(i, 1, n) {
    scanf("%d", dad+i);
    dad[i]--;
    E[dad[i]].push_back(i);
  }

  for (int x = n-1; x >= 0; --x) {
    int m = E[x].size();
    REP(i, m+1) REP(c, 2) REP(s, 4) g[i][c][s] = 0;
    g[0][0][0] = 1;
    REP(i, m) REP(c, 2) REP(s, 4) {
      REP(cur, 2)
        g[i+1][c^cur][s | (1<<cur)] = add(g[i+1][c^cur][s | (1<<cur)], mul(g[i][c][s], f[E[x][i]][cur]));
      g[i+1][c][s] = add(g[i+1][c][s], g[i][c][s]);
    }

    REP(c, 2) REP(s, 4) {
      f[x][c^1] = add(f[x][c^1], g[m][c][s]);
      if (s == 3 || (s == 2 && c == 0))
        f[x][c^1] = add(f[x][c^1], g[m][c][s]);
    }
  }

  int ans = add(f[0][0], f[0][1]);
  printf("%d\n", ans);
  return 0;
}


#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAXN = 100010;

const int mod = 1e9 + 7;

int add(int a, int b) {
  return a+b >= mod ? a+b-mod : a+b;
}

int mul(int a, int b) {
  return (llint(a)*b)%mod;
}

int dad[MAXN];
int f[MAXN][2];
int g[MAXN][2][2];
vector<int> E[MAXN];

void solve(int x) {
  int m = E[x].size();
  REP(i, m+1) REP(cnt, 2) REP(last, 2) g[i][cnt][last] = 0;
  g[0][1][1] = 1;
  REP(i, m) REP(cnt, 2) REP(last, 2)  {
    REP(cur, 2)
      g[i+1][cnt^cur][cnt] = add(g[i+1][cnt^cur][cnt], mul(g[i][cnt][last], f[E[x][i]][cur]));
    g[i+1][cnt][last] = add(g[i+1][cnt][last], g[i][cnt][last]);
  }
}

int main(void) {
  int n;
  scanf("%d", &n);
  FOR(i, 1, n) {
    scanf("%d", dad+i);
    dad[i]--;
    E[dad[i]].push_back(i);
  }

  for (int i = n-1; i >= 0; --i) {
    solve(i);
    int m = E[i].size();
    f[i][0] = add(f[i][0], add(g[m][0][0], g[m][0][1]));
    f[i][1] = add(f[i][1], add(g[m][1][0], g[m][1][1]));

    reverse(E[i].begin(), E[i].end());
    solve(i);

    f[i][0] = add(f[i][0], g[m][0][0]);
    f[i][1] = add(f[i][1], g[m][1][0]);
  }

  int ans = add(f[0][0], f[0][1]);
  printf("%d\n", ans);
  return 0;
}


#include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int mod = 1e9 + 7;
const int N = 100000;

int n, memo[N][2];
vector<vi> e;

void rec(int c, int p){

	for(int i : e[c]) if(i != p) rec(i, c);
	rep(use, 2){
		ll res = 0;

		vector<vi> dp;

		rep(it, 2){
			dp = vector<vi>(2, vi(2));
			dp[0][1] = 1;

			for(int i : e[c]) if(i != p){

				dp[1] = dp[0];
				rep(j, 2) rep(k, 2) (dp[1][j ^ k] += (dp[0][j] * (ll)memo[i][k] % mod)) %= mod;
				dp[0] = dp[1];
			}
			res += dp[0][use];
			reverse(all(e[c]));
		}
		if(use == 1) res += mod - 1;

		if(use == 1){
			dp = vector<vi>(2, vi(2));
			dp[0][1] = 1;
			for(int i : e[c]) if(i != p){

				dp[1] = dp[0];
				rep(j, 2){
					(dp[1][j] += (dp[0][j] * (ll)memo[i][0] % mod)) %= mod;
					res += mod - dp[0][j] * (ll)memo[i][0] % mod;
				}
				dp[0] = dp[1];
			}
		}
		if(use == 0){
			dp = vector<vi>(2, vi(2));
			dp[0][1] = 1;
			for(int i : e[c]) if(i != p){

				dp[1] = dp[0];
				rep(j, 2){
					(dp[1][j ^ 1] += (dp[0][j] * (ll)memo[i][1] % mod)) %= mod;
					if(j == 1) res += mod - dp[0][j] * (ll)memo[i][1] % mod;
				}
				dp[0] = dp[1];
			}
		}
		res %= mod;
		//cerr<<"c: "<<c<<" use: "<<use<<" res: "<<res<<endl;

		memo[c][use] = res;
	}
}

int main(){
	cin >> n;
	e.clear(); e.resize(n);
	rep(i, n - 1){
		int a, b;
		cin >> a; a--;
		e[i + 1].pb(a);
		e[a].pb(i + 1);
	}
	rec(0, 0);
	cout << (memo[0][0] + memo[0][1]) % mod << endl;

	return 0;
}


#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;

const int MAXN = 100000;
const i64 P = 1000000000 + 7;

i64 ways[MAXN][2];
i64 w[MAXN][2][4];
i64 ww[2][4];
vi e[MAXN];

void dfs(int v) {
    w[v][1][0] = 1;
    forn(i, e[v].size()) {
        int u = e[v][i];
        dfs(u);
        forn(j, 2) forn(k, 4) ww[j][k] = 0;
        forn(s, 2) forn(j, 2) forn(k, 4) {
            ww[s ^ j][k | (1 << s)] += w[v][j][k] * ways[u][s];
            ww[s ^ j][k | (1 << s)] %= P;
        }
        forn(j, 2) forn(k, 4) {
            w[v][j][k] += ww[j][k];
            w[v][j][k] %= P;
        }
    }
    forn(j, 2) forn(k, 4) {
        int s = 1;
        if (k == 3 || j == 1 && k == 2) s = 2;
        ways[v][j] += s * w[v][j][k];
        ways[v][j] %= P;
    }
//    cerr << v << ' ' << ways[v][0] << ' ' << ways[v][1] << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int N;
    cin >> N;
    forn(i, N - 1) {
        int x;
        cin >> x;
        e[x - 1].pb(i + 1);
    }
    dfs(0);
    i64 ans = ways[0][0] + ways[0][1];
    cout << ans % P << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author I
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        final int mod = (int) (1e9 + 7);
        int n;
        ArrayList<Integer>[] gr;
        long[][] dp;

        void dfs(int v) {
//        System.err.println("v: " + v);
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);
                dfs(to);
            }

            dp[v][0] = 0;
            dp[v][1] = 1;
//        if (gr[v].size() == 0) return;
            for (int iter = 0; iter < gr[v].size(); iter++) {
                int to = gr[v].get(iter);
                long n0 = (dp[v][1] * dp[to][1] % mod + dp[v][0] * dp[to][0] % mod + dp[v][0]) % mod;
                long n1 = (dp[v][1] * dp[to][0] % mod + dp[v][0] * dp[to][1] % mod + dp[v][1]) % mod;
                //
                dp[v][0] = n0;
                dp[v][1] = n1;
            }

            dp[v][0] = 2 * dp[v][0] % mod;
            dp[v][1] = 2 * dp[v][1] % mod;

            long a00 = 1; // кол-во, 0или1
            long a10 = 0;
            long a01 = 1;
            long a11 = 0;
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);

                long na00 = (a00 + a10 * dp[to][0]) % mod;
                long na10 = (a10 + a00 * dp[to][0]) % mod;
                long na01 = (a01 + a11 * dp[to][1]) % mod;
                long na11 = (a11 + a01 * dp[to][1]) % mod;

                a00 = na00;
                a10 = na10;
                a01 = na01;
                a11 = na11;
            }

            dp[v][0] = (dp[v][0] + mod - a11) % mod;
            dp[v][1] = (dp[v][1] + mod - a00 + mod - a10) % mod;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.readInt();
            gr = new ArrayList[n + 1];
            for (int v = 1; v <= n; v++) {
                gr[v] = new ArrayList(1);
            }

            for (int i = 2; i <= n; i++) {
                int p = in.readInt();
                gr[p].add(i);
            }

            dp = new long[n + 1][2];
            dfs(1);
            out.printLine((dp[1][0] + dp[1][1]) % mod);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author I
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        static final int mod = (int) (1e9 + 7);
        int n;
        ArrayList<Integer>[] gr;
        long[][] dp;

        void dfs(int v) {
//        System.err.println("v: " + v);
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);
                dfs(to);
            }

            dp[v][0] = 0;
            dp[v][1] = 1;
//        if (gr[v].size() == 0) return;
            for (int iter = 0; iter < gr[v].size(); iter++) {
                int to = gr[v].get(iter);
                long n0 = (dp[v][1] * dp[to][1] % mod + dp[v][0] * dp[to][0] % mod + dp[v][0]) % mod;
                long n1 = (dp[v][1] * dp[to][0] % mod + dp[v][0] * dp[to][1] % mod + dp[v][1]) % mod;
                //
                dp[v][0] = n0;
                dp[v][1] = n1;
            }

            dp[v][0] = 2 * dp[v][0] % mod;
            dp[v][1] = 2 * dp[v][1] % mod;

            long a00 = 1; // кол-во, 0или1
            long a10 = 0;
            long a01 = 1;
            long a11 = 0;
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);

                long na00 = (a00 + a10 * dp[to][0]) % mod;
                long na10 = (a10 + a00 * dp[to][0]) % mod;
                long na01 = (a01 + a11 * dp[to][1]) % mod;
                long na11 = (a11 + a01 * dp[to][1]) % mod;

                a00 = na00;
                a10 = na10;
                a01 = na01;
                a11 = na11;
            }

            dp[v][0] = (dp[v][0] + mod - a11) % mod;
            dp[v][1] = (dp[v][1] + mod - a00 + mod - a10) % mod;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.readInt();
            gr = new ArrayList[n + 1];
            for (int v = 1; v <= n; v++) {
                gr[v] = new ArrayList(1);
            }

            for (int i = 2; i <= n; i++) {
                int p = in.readInt();
                gr[p].add(i);
            }

            dp = new long[n + 1][2];
            dfs(1);
            out.printLine((dp[1][0] + dp[1][1]) % mod);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Egor Kulikov (egor@egork.net)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        final long mod = (long) (1e9 + 7);
        int n;
        IntArrayList[] gr;
        long[][] dp;

        void dfs(int v) {
//        System.err.println("v: " + v);
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);
                dfs(to);
            }

            dp[v][0] = 0;
            dp[v][1] = 1;
//        if (gr[v].size() == 0) return;
            for (int iter = 0; iter < gr[v].size(); iter++) {
                int to = gr[v].get(iter);
                long n0 = (dp[v][1] * dp[to][1] % mod + dp[v][0] * dp[to][0] % mod + dp[v][0]) % mod;
                long n1 = (dp[v][1] * dp[to][0] % mod + dp[v][0] * dp[to][1] % mod + dp[v][1]) % mod;
                //
                dp[v][0] = n0;
                dp[v][1] = n1;
            }

            dp[v][0] = 2 * dp[v][0] % mod;
            dp[v][1] = 2 * dp[v][1] % mod;

            long a00 = 1; // кол-во, 0или1
            long a10 = 0;
            long a01 = 1;
            long a11 = 0;
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);

                long na00 = (a00 + a10 * dp[to][0]) % mod;
                long na10 = (a10 + a00 * dp[to][0]) % mod;
                long na01 = (a01 + a11 * dp[to][1]) % mod;
                long na11 = (a11 + a01 * dp[to][1]) % mod;

                a00 = na00;
                a10 = na10;
                a01 = na01;
                a11 = na11;
            }

            dp[v][0] = (dp[v][0] + mod - a11) % mod;
            dp[v][1] = (dp[v][1] + mod - a00 + mod - a10) % mod;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.readInt();
            gr = new IntArrayList[n + 1];
            for (int v = 1; v <= n; v++) {
                gr[v] = new IntArrayList();
            }

            for (int i = 2; i <= n; i++) {
                int p = in.readInt();
                gr[p].add(i);
            }

            dp = new long[n + 1][2];
            dfs(1);
            out.printLine((dp[1][0] + dp[1][1]) % mod);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }

    }

    static class IntArrayList extends IntList {
        private int[] array;
        private int size;

        public IntArrayList() {
            this(10);
        }

        public IntArrayList(int capacity) {
            array = new int[capacity];
        }

        public IntArrayList(IntList list) {
            this(list.size());
            addAll(list);
        }

        public int get(int index) {
            if (index >= size)
                throw new IndexOutOfBoundsException();
            return array[index];
        }

        public int size() {
            return size;
        }

        public void add(int value) {
            ensureCapacity(size + 1);
            array[size++] = value;
        }

        public void ensureCapacity(int newCapacity) {
            if (newCapacity > array.length) {
                int[] newArray = new int[Math.max(newCapacity, array.length << 1)];
                System.arraycopy(array, 0, newArray, 0, size);
                array = newArray;
            }
        }

    }

    static abstract class IntList extends IntCollection implements Comparable<IntList> {
        public abstract int get(int index);

        public IntIterator iterator() {
            return new IntIterator() {
                private int size = size();
                private int index = 0;

                public int value() throws NoSuchElementException {
                    if (!isValid())
                        throw new NoSuchElementException();
                    return get(index);
                }

                public void advance() throws NoSuchElementException {
                    if (!isValid())
                        throw new NoSuchElementException();
                    index++;
                }

                public boolean isValid() {
                    return index < size;
                }
            };
        }

        public int hashCode() {
            int hashCode = 1;
            for (IntIterator i = iterator(); i.isValid(); i.advance())
                hashCode = 31 * hashCode + i.value();
            return hashCode;
        }

        public boolean equals(Object obj) {
            if (!(obj instanceof IntList))
                return false;
            IntList list = (IntList) obj;
            if (list.size() != size())
                return false;
            IntIterator i = iterator();
            IntIterator j = list.iterator();
            while (i.isValid()) {
                if (i.value() != j.value())
                    return false;
                i.advance();
                j.advance();
            }
            return true;
        }

        public int compareTo(IntList o) {
            IntIterator i = iterator();
            IntIterator j = o.iterator();
            while (true) {
                if (i.isValid()) {
                    if (j.isValid()) {
                        if (i.value() != j.value()) {
                            if (i.value() < j.value())
                                return -1;
                            else
                                return 1;
                        }
                    } else
                        return 1;
                } else {
                    if (j.isValid())
                        return -1;
                    else
                        return 0;
                }
                i.advance();
                j.advance();
            }
        }

    }

    static abstract class IntCollection {
        public abstract IntIterator iterator();

        public abstract int size();

        public abstract void add(int value);

        public void addAll(IntCollection values) {
            for (IntIterator it = values.iterator(); it.isValid(); it.advance()) {
                add(it.value());
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static interface IntIterator {
        public int value();

        public void advance();

        public boolean isValid();

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Egor Kulikov (egor@egork.net)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        final int mod = (int) (1e9 + 7);
        int n;
        ArrayList<Integer>[] gr;
        long[][] dp;

        void dfs(int v) {
//        System.err.println("v: " + v);
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);
                dfs(to);
            }

            dp[v][0] = 0;
            dp[v][1] = 1;
//        if (gr[v].size() == 0) return;
            for (int iter = 0; iter < gr[v].size(); iter++) {
                int to = gr[v].get(iter);
                long n0 = (dp[v][1] * dp[to][1] % mod + dp[v][0] * dp[to][0] % mod + dp[v][0]) % mod;
                long n1 = (dp[v][1] * dp[to][0] % mod + dp[v][0] * dp[to][1] % mod + dp[v][1]) % mod;
                //
                dp[v][0] = n0;
                dp[v][1] = n1;
            }

            dp[v][0] = 2 * dp[v][0] % mod;
            dp[v][1] = 2 * dp[v][1] % mod;

            long a00 = 1; // кол-во, 0или1
            long a10 = 0;
            long a01 = 1;
            long a11 = 0;
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);

                long na00 = (a00 + a10 * dp[to][0]) % mod;
                long na10 = (a10 + a00 * dp[to][0]) % mod;
                long na01 = (a01 + a11 * dp[to][1]) % mod;
                long na11 = (a11 + a01 * dp[to][1]) % mod;

                a00 = na00;
                a10 = na10;
                a01 = na01;
                a11 = na11;
            }

            dp[v][0] = (dp[v][0] + mod - a11) % mod;
            dp[v][1] = (dp[v][1] + mod - a00 + mod - a10) % mod;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.readInt();
            gr = new ArrayList[n + 1];
            for (int v = 1; v <= n; v++) {
                gr[v] = new ArrayList(1);
            }

            for (int i = 2; i <= n; i++) {
                int p = in.readInt();
                gr[p].add(i);
            }

            dp = new long[n + 1][2];
            dfs(1);
            out.printLine((dp[1][0] + dp[1][1]) % mod);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.NoSuchElementException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Egor Kulikov (egor@egork.net)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        final int mod = (int) (1e9 + 7);
        int n;
        IntArrayList[] gr;
        long[][] dp;

        void dfs(int v) {
//        System.err.println("v: " + v);
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);
                dfs(to);
            }

            dp[v][0] = 0;
            dp[v][1] = 1;
//        if (gr[v].size() == 0) return;
            for (int iter = 0; iter < gr[v].size(); iter++) {
                int to = gr[v].get(iter);
                long n0 = (dp[v][1] * dp[to][1] % mod + dp[v][0] * dp[to][0] % mod + dp[v][0]) % mod;
                long n1 = (dp[v][1] * dp[to][0] % mod + dp[v][0] * dp[to][1] % mod + dp[v][1]) % mod;
                //
                dp[v][0] = n0;
                dp[v][1] = n1;
            }

            dp[v][0] = 2 * dp[v][0] % mod;
            dp[v][1] = 2 * dp[v][1] % mod;

            long a00 = 1; // кол-во, 0или1
            long a10 = 0;
            long a01 = 1;
            long a11 = 0;
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);

                long na00 = (a00 + a10 * dp[to][0]) % mod;
                long na10 = (a10 + a00 * dp[to][0]) % mod;
                long na01 = (a01 + a11 * dp[to][1]) % mod;
                long na11 = (a11 + a01 * dp[to][1]) % mod;

                a00 = na00;
                a10 = na10;
                a01 = na01;
                a11 = na11;
            }

            dp[v][0] = (dp[v][0] + mod - a11) % mod;
            dp[v][1] = (dp[v][1] + mod - a00 + mod - a10) % mod;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.readInt();
            gr = new IntArrayList[n + 1];
            for (int v = 1; v <= n; v++) {
                gr[v] = new IntArrayList();
            }

            for (int i = 2; i <= n; i++) {
                int p = in.readInt();
                gr[p].add(i);
            }

            dp = new long[n + 1][2];
            dfs(1);
            out.printLine((dp[1][0] + dp[1][1]) % mod);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }

    }

    static class IntArrayList extends IntList {
        private int[] array;
        private int size;

        public IntArrayList() {
            this(10);
        }

        public IntArrayList(int capacity) {
            array = new int[capacity];
        }

        public IntArrayList(IntList list) {
            this(list.size());
            addAll(list);
        }

        public int get(int index) {
            if (index >= size)
                throw new IndexOutOfBoundsException();
            return array[index];
        }

        public int size() {
            return size;
        }

        public void add(int value) {
            ensureCapacity(size + 1);
            array[size++] = value;
        }

        public void ensureCapacity(int newCapacity) {
            if (newCapacity > array.length) {
                int[] newArray = new int[Math.max(newCapacity, array.length << 1)];
                System.arraycopy(array, 0, newArray, 0, size);
                array = newArray;
            }
        }

    }

    static abstract class IntList extends IntCollection implements Comparable<IntList> {
        public abstract int get(int index);

        public IntIterator iterator() {
            return new IntIterator() {
                private int size = size();
                private int index = 0;

                public int value() throws NoSuchElementException {
                    if (!isValid())
                        throw new NoSuchElementException();
                    return get(index);
                }

                public void advance() throws NoSuchElementException {
                    if (!isValid())
                        throw new NoSuchElementException();
                    index++;
                }

                public boolean isValid() {
                    return index < size;
                }
            };
        }

        public int hashCode() {
            int hashCode = 1;
            for (IntIterator i = iterator(); i.isValid(); i.advance())
                hashCode = 31 * hashCode + i.value();
            return hashCode;
        }

        public boolean equals(Object obj) {
            if (!(obj instanceof IntList))
                return false;
            IntList list = (IntList) obj;
            if (list.size() != size())
                return false;
            IntIterator i = iterator();
            IntIterator j = list.iterator();
            while (i.isValid()) {
                if (i.value() != j.value())
                    return false;
                i.advance();
                j.advance();
            }
            return true;
        }

        public int compareTo(IntList o) {
            IntIterator i = iterator();
            IntIterator j = o.iterator();
            while (true) {
                if (i.isValid()) {
                    if (j.isValid()) {
                        if (i.value() != j.value()) {
                            if (i.value() < j.value())
                                return -1;
                            else
                                return 1;
                        }
                    } else
                        return 1;
                } else {
                    if (j.isValid())
                        return -1;
                    else
                        return 0;
                }
                i.advance();
                j.advance();
            }
        }

    }

    static abstract class IntCollection {
        public abstract IntIterator iterator();

        public abstract int size();

        public abstract void add(int value);

        public void addAll(IntCollection values) {
            for (IntIterator it = values.iterator(); it.isValid(); it.advance()) {
                add(it.value());
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static interface IntIterator {
        public int value();

        public void advance();

        public boolean isValid();

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Egor Kulikov (egor@egork.net)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        final int mod = (int) (1e9 + 7);
        int n;
        ArrayList<Integer>[] gr;
        long[][] dp;

        void dfs(int v) {
//        System.err.println("v: " + v);
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);
                dfs(to);
            }

            dp[v][0] = 0;
            dp[v][1] = 1;
//        if (gr[v].size() == 0) return;
            for (int iter = 0; iter < gr[v].size(); iter++) {
                int to = gr[v].get(iter);
                long n0 = (dp[v][1] * dp[to][1] % mod + dp[v][0] * dp[to][0] % mod + dp[v][0]) % mod;
                long n1 = (dp[v][1] * dp[to][0] % mod + dp[v][0] * dp[to][1] % mod + dp[v][1]) % mod;
                //
                dp[v][0] = n0;
                dp[v][1] = n1;
            }

            dp[v][0] = 2 * dp[v][0] % mod;
            dp[v][1] = 2 * dp[v][1] % mod;

            long a00 = 1; // кол-во, 0или1
            long a10 = 0;
            long a01 = 1;
            long a11 = 0;
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);

                long na00 = (a00 + a10 * dp[to][0]) % mod;
                long na10 = (a10 + a00 * dp[to][0]) % mod;
                long na01 = (a01 + a11 * dp[to][1]) % mod;
                long na11 = (a11 + a01 * dp[to][1]) % mod;

                a00 = na00;
                a10 = na10;
                a01 = na01;
                a11 = na11;
            }

            dp[v][0] = (dp[v][0] + mod - a11) % mod;
            dp[v][1] = (dp[v][1] + mod - a00 + mod - a10) % mod;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.readInt();
            gr = new ArrayList[n + 1];
            for (int v = 1; v <= n; v++) {
                gr[v] = new ArrayList(0);
            }

            for (int i = 2; i <= n; i++) {
                int p = in.readInt();
                gr[p].add(i);
            }

            dp = new long[n + 1][2];
            dfs(1);
            out.printLine((dp[1][0] + dp[1][1]) % mod);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Egor Kulikov (egor@egork.net)
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        OutputWriter out = new OutputWriter(outputStream);
        TaskD solver = new TaskD();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskD {
        final int mod = (int) (1e9 + 7);
        int n;
        ArrayList<Integer>[] gr;
        long[][] dp;

        void dfs(int v) {
//        System.err.println("v: " + v);
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);
                dfs(to);
            }

            dp[v][0] = 0;
            dp[v][1] = 1;
//        if (gr[v].size() == 0) return;
            for (int iter = 0; iter < gr[v].size(); iter++) {
                int to = gr[v].get(iter);
                long n0 = (dp[v][1] * dp[to][1] % mod + dp[v][0] * dp[to][0] % mod + dp[v][0]) % mod;
                long n1 = (dp[v][1] * dp[to][0] % mod + dp[v][0] * dp[to][1] % mod + dp[v][1]) % mod;
                //
                dp[v][0] = n0;
                dp[v][1] = n1;
            }

            dp[v][0] = 2 * dp[v][0] % mod;
            dp[v][1] = 2 * dp[v][1] % mod;

            long a00 = 1; // кол-во, 0или1
            long a10 = 0;
            long a01 = 1;
            long a11 = 0;
            for (int i = 0; i < gr[v].size(); i++) {
                int to = gr[v].get(i);

                long na00 = (a00 + a10 * dp[to][0]) % mod;
                long na10 = (a10 + a00 * dp[to][0]) % mod;
                long na01 = (a01 + a11 * dp[to][1]) % mod;
                long na11 = (a11 + a01 * dp[to][1]) % mod;

                a00 = na00;
                a10 = na10;
                a01 = na01;
                a11 = na11;
            }

            dp[v][0] = (dp[v][0] + mod - a11) % mod;
            dp[v][1] = (dp[v][1] + mod - a00 + mod - a10) % mod;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.readInt();
            gr = new ArrayList[n + 1];
            for (int v = 1; v <= n; v++) {
                gr[v] = new ArrayList(10);
            }

            for (int i = 2; i <= n; i++) {
                int p = in.readInt();
                gr[p].add(i);
            }

            dp = new long[n + 1][2];
            dfs(1);
            out.printLine((dp[1][0] + dp[1][1]) % mod);
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void printLine(long i) {
            writer.println(i);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}


import java.io.*;
import java.util.*;

public class D {

	static void solve() throws IOException {
		int n = nextInt();
		List<Integer>[] edges = new List[n];
		for (int i = 0; i < n; i++) {
			edges[i] = new ArrayList<>();
		}
		for (int i = 1; i < n; i++) {
			int x = nextInt() - 1;
			edges[x].add(i);
		}
		int[][] dp = new int[2][n];
		for (int v = n - 1; v >= 0; v--) {
			int even = 1;
			int odd = 0;
			for (int e = 0; e < edges[v].size(); e++) {
				int to = edges[v].get(e);
				int neven = add(mul(even, add(dp[0][to], 1)),
						mul(odd, dp[1][to]));
				int nodd = add(mul(even, dp[1][to]),
						mul(odd, add(dp[0][to], 1)));
				even = neven;
				odd = nodd;
			}
			even = add(even, even);
			odd = add(odd, odd);
			int[][][][] cdp = new int[2][2][2][edges[v].size() + 1];
			cdp[0][1][1][0] = 1;
			cdp[0][0][1][0] = 1;
			for (int e = 0; e < edges[v].size(); e++) {
				int to = edges[v].get(e);
				for (int oddity = 0; oddity < 2; oddity++) {
					for (int prev = 0; prev < 2; prev++) {
						for (int current = 0; current < 2; current++) {
							int val = cdp[oddity][prev][current][e];
							if (val == 0)
								continue;
							cdp[oddity][prev][current][e + 1] = add(
									cdp[oddity][prev][current][e + 1], val);
							for (int get = 0; get < 2; get++) {
								if ((current ^ get) == prev)
									cdp[get ^ oddity][current][current ^ get][e + 1] = add(
											cdp[get ^ oddity][current][current
													^ get][e + 1],
											mul(val, dp[get][to]));
							}
						}
					}
				}
			}
			even = add(even, MOD - cdp[0][1][1][edges[v].size()]);
			even = add(even, MOD - cdp[0][1][0][edges[v].size()]);
			odd = add(odd, MOD - cdp[1][1][1][edges[v].size()]);
			odd = add(odd, MOD - cdp[1][1][0][edges[v].size()]);
			dp[0][v] = odd;
			dp[1][v] = even;
		}
		out.println(add(dp[0][0], dp[1][0]));
	}

	static final int MOD = 1000000007;

	static int add(int a, int b) {
		a += b;
		if (a >= MOD)
			a -= MOD;
		return a;
	}

	static int mul(int a, int b) {
		return (int) ((long) a * b % MOD);
	}

	static BufferedReader br;
	static StringTokenizer st;
	static PrintWriter out;

	public static void main(String[] args) throws IOException {
		InputStream input = System.in;
		PrintStream output = System.out;
		File file = new File("d.in");
		if (file.exists() && file.canRead()) {
			input = new FileInputStream(file);
			output = new PrintStream("d.out");
		}
		br = new BufferedReader(new InputStreamReader(input));
		out = new PrintWriter(output);
		solve();
		out.close();
		br.close();
	}

	static boolean hasNext() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = br.readLine();
			if (line == null) {
				return false;
			}
			st = new StringTokenizer(line);
		}
		return true;
	}

	static String next() throws IOException {
		return hasNext() ? st.nextToken() : null;
	}

	static int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	static double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}


import java.io.*;
import java.util.*;

public class D {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	static final int P = 1_000_000_007;

	List<Integer>[] g;

	int[] go(int v) {
		int[][][] tmp = new int[2][2][4];
		tmp[0][1][0] = 1;
		for (int i = 0; i < g[v].size(); i++) {
			int[] dp = go(g[v].get(i));
			int[][][] next = new int[2][2][4];

			for (int j0 = 0; j0 < 2; j0++)
				for (int j1 = 0; j1 < 2; j1++)
					for (int has = 0; has < 4; has++) {
						for (int pick = 0; pick < 2; pick++) {
							int ways = (int) ((long) tmp[j0][j1][has]
									* dp[pick] % P);
//							if (ways != 0) {
//								System.err.println(j0 + " " + j1 + " " + has
//										+ " " + pick + " " + ways);
//							}
							next[j0 ^ 1][j1 ^ pick][has | (1 << pick)] += ways;
							next[j0 ^ 1][j1 ^ pick][has | (1 << pick)] %= P;

						}
						next[j0][j1][has] += tmp[j0][j1][has];
						next[j0][j1][has] %= P;
					}
			tmp = next;
		}

//		System.err.println("!");
		int[] ret = new int[2];
		for (int j0 = 0; j0 < 2; j0++)
			for (int j1 = 0; j1 < 2; j1++)
				for (int has = 0; has < 4; has++) {
					if (tmp[j0][j1][has] != 0) {
						// System.err.println(j0 + " " + j1 + " " + has + " "
						// + tmp[j0][j1][has]);
					}
					if ((j0 & 1) == 0) {
						if (has == 2 || has == 3) {
							tmp[j0][j1][has] *= 2;
							tmp[j0][j1][has] %= P;
						}
					} else {
						if (has == 3) {
							tmp[j0][j1][has] *= 2;
							tmp[j0][j1][has] %= P;
						}
					}
					ret[j1] += tmp[j0][j1][has];
					ret[j1] %= P;
				}
		return ret;

	}

	void solve() throws IOException {
		int n = nextInt();
		g = new List[n];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<>(0);
		}
		for (int i = 1; i < n; i++) {
			int p = nextInt() - 1;
			g[p].add(i);
		}

		int[] ans = go(0);
		out.println((ans[0] + ans[1]) % P);
	}

	D() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new D();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}


import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
    static final long MODULO = (int) (1e9 + 7);

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int[] p = new int[n];
        p[0] = -1;
        for (int i = 1; i < n; ++i) p[i] = in.nextInt() - 1;
        int[] firstChild = new int[n];
        int[] nextSibling = new int[n];
        Arrays.fill(firstChild, -1);
        for (int i = n - 1; i >= 1; --i) {
            nextSibling[i] = firstChild[p[i]];
            firstChild[p[i]] = i;
        }
        long[] waysOdd = new long[n];
        long[] waysEven = new long[n];
        for (int v = n - 1; v >= 0; --v) {
            waysOdd[v] = 1;
            waysEven[v] = 0;
            long waysOddAllOdd = 1;
            long waysOddAllEven = 1;
            long waysEvenAllOdd = 0;
            long waysEvenAllEven = 0;
            int child = firstChild[v];
            while (child >= 0) {
                long nodd = (waysOdd[v] * (1 + waysEven[child]) + waysEven[v] * waysOdd[child]) % MODULO;
                long neven = (waysEven[v] * (1 + waysEven[child]) + waysOdd[v] * waysOdd[child]) % MODULO;
                waysOdd[v] = nodd;
                waysEven[v] = neven;
                nodd = (waysOddAllOdd + waysEvenAllOdd * waysOdd[child]) % MODULO;
                neven = (waysEvenAllOdd + waysOddAllOdd * waysOdd[child]) % MODULO;
                waysOddAllOdd = nodd;
                waysEvenAllOdd = neven;
                nodd = (waysOddAllEven * (1 + waysEven[child])) % MODULO;
                neven = (waysEvenAllEven * (1 + waysEven[child])) % MODULO;
                waysOddAllEven = nodd;
                waysEvenAllEven = neven;
                child = nextSibling[child];
            }
            waysOdd[v] = (waysOdd[v] * 2 - waysOddAllEven + 2 * MODULO) % MODULO;
            waysEven[v] = (waysEven[v] * 2 - waysEvenAllOdd - waysEvenAllEven + 2 * MODULO) % MODULO;
        }
        out.println((waysOdd[0] + waysEven[0]) % MODULO);
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

}


#include<bits/stdc++.h>
#define ll long long
const int md=1000000007;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
/* VECTORS */
#define pb push_back
#define co(v,x) count(v.begin(),v.end(),x)
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define vi vector<int>
#define vll vector<ll>
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.begin(),v.end(),greater<int>())
/* INPUT/OUTPUT*/
#define pr printf
#define sc scanf
#define pi(a) printf("%d\n",a)
#define pll(a) printf("%lld\n",a)
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
/* LOOPS*/
#define fi(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
using namespace std::chrono;
ll pw(ll a, ll b)
{
    ll c=1,m=a;
    while (b)
    {
        if(b&1) c=(c * m);
        m=(m*m);
        b/=2;
    }
    return c;
}
ll pwmd(ll a,ll b)
{
    ll c=1,m=a;
    while(b)
    {
        if(b&1) c=(c*m)%md;
        m=(m*m)%md;
        b/=2;
    }
    return c;
}
ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll ceel(ll a,ll b)
{
    if(a%b==0) return a/b;
    else return a/b+1;
}
ll my_log(ll n, ll b)
{
    ll i=1;
    ll ans=0;
    while(1)
    {
        if(i>n)
        {
            ans--;
            break;
        }
        if(i==n) break;
        i*=b;
        ans++;
    }
    return ans;
}
bool is(string r)
{
    string p = r;
    reverse(p.begin(), p.end());
    return (r == p);
}
int l_p_p(const string &s)
{
    string kmprev = s;
    std::reverse(kmprev.begin(), kmprev.end());
    string kmp = s + "#" + kmprev;
    vector<int> lps(kmp.size(), 0);
    for (int i = 1; i < (int)lps.size(); ++i)
    {
        int prev_idx = lps[i - 1];
        while (prev_idx > 0 && kmp[i] != kmp[prev_idx])
        {
            prev_idx = lps[prev_idx - 1];
        }
        lps[i] = prev_idx + (kmp[i] == kmp[prev_idx] ? 1 : 0);
    }
    return lps[lps.size() - 1];
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
   /* auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr << "Time taken: "
         << duration.count()<< "ms" <<"\n";*/
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    fast;
    int n,m,d,c,s=0;
    cin>>n>>m>>d;
    vi v;
    fi(i,0,m) cin>>c,v.pb(c),s+=c;
    if(s+(m+1)*(d-1)<n) cout<<"NO";
    else
    {
        cout<<"YES\n";
        int x=n-s;
        int y=x/(d-1);
        int z=x%(d-1);
        fi(i,0,y)
        {
            fi(i,0,d-1) cout<<0<<" ";
            fi(j,0,v[i]) cout<<i+1<<" ";
        }
        fi(i,0,z) cout<<0<<" ";
        fi(i,y,m) cout<<i+1<<" ";
    }
}


#include<bits/stdc++.h>
#define ll long long
const int md=1000000007;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
/* VECTORS */
#define pb push_back
#define co(v,x) count(v.begin(),v.end(),x)
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define vi vector<int>
#define vll vector<ll>
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.begin(),v.end(),greater<int>())
/* INPUT/OUTPUT*/
#define pr printf
#define sc scanf
#define pi(a) printf("%d\n",a)
#define pll(a) printf("%lld\n",a)
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
/* LOOPS*/
#define fi(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
using namespace std::chrono;
ll pw(ll a, ll b)
{
    ll c=1,m=a;
    while (b)
    {
        if(b&1) c=(c * m);
        m=(m*m);
        b/=2;
    }
    return c;
}
ll pwmd(ll a,ll b)
{
    ll c=1,m=a;
    while(b)
    {
        if(b&1) c=(c*m)%md;
        m=(m*m)%md;
        b/=2;
    }
    return c;
}
ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll ceel(ll a,ll b)
{
    if(a%b==0) return a/b;
    else return a/b+1;
}
ll my_log(ll n, ll b)
{
    ll i=1;
    ll ans=0;
    while(1)
    {
        if(i>n)
        {
            ans--;
            break;
        }
        if(i==n) break;
        i*=b;
        ans++;
    }
    return ans;
}
bool is(string r)
{
    string p = r;
    reverse(p.begin(), p.end());
    return (r == p);
}
int l_p_p(const string &s)
{
    string kmprev = s;
    std::reverse(kmprev.begin(), kmprev.end());
    string kmp = s + "#" + kmprev;
    vector<int> lps(kmp.size(), 0);
    for (int i = 1; i < (int)lps.size(); ++i)
    {
        int prev_idx = lps[i - 1];
        while (prev_idx > 0 && kmp[i] != kmp[prev_idx])
        {
            prev_idx = lps[prev_idx - 1];
        }
        lps[i] = prev_idx + (kmp[i] == kmp[prev_idx] ? 1 : 0);
    }
    return lps[lps.size() - 1];
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
   /* auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr << "Time taken: "
         << duration.count()<< "ms" <<"\n";*/
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    fast;
    int n,m,d,c,s=0;
    cin>>n>>m>>d;
    vi v;
    fi(i,0,m) cin>>c,v.pb(c),s+=c;
    v.pb(0);
    if(s+(m+1)*(d-1)<n) cout<<"NO";
    else
    {
        cout<<"YES\n";
        int x=n-s;
        int y=x/(d-1);
        int z=x%(d-1);
        fi(i,0,y)
        {
            fi(j,0,d-1) cout<<0<<" ";
            fi(j,0,v[i]) cout<<i+1<<" ";
        }
        fi(i,0,z) cout<<0<<" ";
        fi(i,y,m) cout<<i+1<<" ";
    }
}


#include<bits/stdc++.h>
#define ll long long
const int md=1000000007;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
/* VECTORS */
#define pb push_back
#define co(v,x) count(v.begin(),v.end(),x)
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define vi vector<int>
#define vll vector<ll>
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.begin(),v.end(),greater<int>())
/* INPUT/OUTPUT*/
#define pr printf
#define sc scanf
#define pi(a) printf("%d\n",a)
#define pll(a) printf("%lld\n",a)
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
/* LOOPS*/
#define fi(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
using namespace std::chrono;
ll pw(ll a, ll b)
{
    ll c=1,m=a;
    while (b)
    {
        if(b&1) c=(c * m);
        m=(m*m);
        b/=2;
    }
    return c;
}
ll pwmd(ll a,ll b)
{
    ll c=1,m=a;
    while(b)
    {
        if(b&1) c=(c*m)%md;
        m=(m*m)%md;
        b/=2;
    }
    return c;
}
ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll ceel(ll a,ll b)
{
    if(a%b==0) return a/b;
    else return a/b+1;
}
ll my_log(ll n, ll b)
{
    ll i=1;
    ll ans=0;
    while(1)
    {
        if(i>n)
        {
            ans--;
            break;
        }
        if(i==n) break;
        i*=b;
        ans++;
    }
    return ans;
}
bool is(string r)
{
    string p = r;
    reverse(p.begin(), p.end());
    return (r == p);
}
int l_p_p(const string &s)
{
    string kmprev = s;
    std::reverse(kmprev.begin(), kmprev.end());
    string kmp = s + "#" + kmprev;
    vector<int> lps(kmp.size(), 0);
    for (int i = 1; i < (int)lps.size(); ++i)
    {
        int prev_idx = lps[i - 1];
        while (prev_idx > 0 && kmp[i] != kmp[prev_idx])
        {
            prev_idx = lps[prev_idx - 1];
        }
        lps[i] = prev_idx + (kmp[i] == kmp[prev_idx] ? 1 : 0);
    }
    return lps[lps.size() - 1];
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
   /* auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr << "Time taken: "
         << duration.count()<< "ms" <<"\n";*/
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    fast;
    int n,m,d,c,s=0;
    cin>>n>>m>>d;
    vi v;
    fi(i,0,m) cin>>c,v.pb(c),s+=c;
    vi ans;
    if(s+(m+1)*(d-1)<n) cout<<"NO";
    else
    {
        cout<<"YES\n";
        int x=n-s;
        int y=x/(d-1);
        int z=x%(d-1);
        fi(i,0,y)
        {
            fi(i,0,d-1) ans.pb(0);
            fi(j,0,v[i]) ans.pb(i+1);
        }
        fi(i,0,z) ans.pb(0);
        fi(i,y,m) ans.pb(i+1);
        fi(i,0,n) cout<<ans[i]<<" ";
    }
}


#include<bits/stdc++.h>
#define ll long long
const int md=1000000007;
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
/* VECTORS */
#define pb push_back
#define co(v,x) count(v.begin(),v.end(),x)
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define vi vector<int>
#define vll vector<ll>
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(v.begin(),v.end(),greater<int>())
/* INPUT/OUTPUT*/
#define pr printf
#define sc scanf
#define pi(a) printf("%d\n",a)
#define pll(a) printf("%lld\n",a)
#define si(a) scanf("%d",&a)
#define sll(a) scanf("%lld",&a)
/* LOOPS*/
#define fi(i,a,b) for(int i=a;i<b;i++)
#define fll(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
using namespace std::chrono;
ll pw(ll a, ll b)
{
    ll c=1,m=a;
    while (b)
    {
        if(b&1) c=(c * m);
        m=(m*m);
        b/=2;
    }
    return c;
}
ll pwmd(ll a,ll b)
{
    ll c=1,m=a;
    while(b)
    {
        if(b&1) c=(c*m)%md;
        m=(m*m)%md;
        b/=2;
    }
    return c;
}
ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll ceel(ll a,ll b)
{
    if(a%b==0) return a/b;
    else return a/b+1;
}
ll my_log(ll n, ll b)
{
    ll i=1;
    ll ans=0;
    while(1)
    {
        if(i>n)
        {
            ans--;
            break;
        }
        if(i==n) break;
        i*=b;
        ans++;
    }
    return ans;
}
bool is(string r)
{
    string p = r;
    reverse(p.begin(), p.end());
    return (r == p);
}
int l_p_p(const string &s)
{
    string kmprev = s;
    std::reverse(kmprev.begin(), kmprev.end());
    string kmp = s + "#" + kmprev;
    vector<int> lps(kmp.size(), 0);
    for (int i = 1; i < (int)lps.size(); ++i)
    {
        int prev_idx = lps[i - 1];
        while (prev_idx > 0 && kmp[i] != kmp[prev_idx])
        {
            prev_idx = lps[prev_idx - 1];
        }
        lps[i] = prev_idx + (kmp[i] == kmp[prev_idx] ? 1 : 0);
    }
    return lps[lps.size() - 1];
}
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
   /* auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cerr << "Time taken: "
         << duration.count()<< "ms" <<"\n";*/
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    fast;
    int n,m,d,c,s=0;
    cin>>n>>m>>d;
    vi v;
    fi(i,0,m) cin>>c,v.pb(c),s+=c;
    v.pb(0);
    if(s+(m+1)*(d-1)<n) cout<<"NO";
    else
    {
        cout<<"YES\n";
        if(d==1)
        {
            fi(i,0,n) cout<<1<<" ";
        }
        else
        {
        int x=n-s;
        int y=x/(d-1);
        int z=x%(d-1);
        fi(i,0,y)
        {
            fi(j,0,d-1) cout<<0<<" ";
            fi(j,0,v[i]) cout<<i+1<<" ";
        }
        fi(i,0,z) cout<<0<<" ";
        fi(i,y,m)
        {
            fi(j,0,v[i]) cout<<i+1<<" ";
        }
        }
    }
}