#include <bits/stdc++.h>
const int MAXN = 500, MOD = 1e9 + 7;
int n, d[MAXN + 5];
inline int qkpow(int a, int b, const int p = MOD) {
  int ret = 1;
  for (; b; a = 1ll * a * a % p, b >>= 1) ret = 1ll * ret * (b & 1 ? a : 1) % p;
  return ret;
}
int main() {
  scanf("%d", &n);
  int ans = (MOD + qkpow(2, n - 1) - 1) % MOD;
  for (int i = 1, f; i <= n; ++i) {
    scanf("%d", &f);
    if (~f) d[i] = -1, ++d[f];
  }
  for (int i = 1; i <= n; ++i) {
    if (~d[i]) {
      ans = (ans - qkpow(2, d[i]) + 1 + MOD) % MOD;
    }
  }
  printf("%d\n", ans);
  return 0;
}
