#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, P = 1e9 + 7;
const double Pi = acos(-1);
inline int read() {
  int x = 0, f = 1, ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
  return x * f;
}
inline int Add(int a, int b) { return a + b >= P ? a + b - P : a + b; }
inline int Sub(int a, int b) { return a - b < 0 ? a - b + P : a - b; }
inline int Mul(int a, int b) {
  long long res = 1ll * a * b;
  return res >= P ? res % P : res;
}
int n, ans;
int qpow(int a, int b) {
  int res = 1;
  while (b) {
    if (b & 1) res = Mul(res, a);
    a = Mul(a, a);
    b >>= 1;
  }
  return res;
}
int a[N];
signed main() {
  n = read();
  for (register int i = 1; i <= n; ++i) {
    int x = read();
    if (x != -1) ++a[x];
  }
  for (register int i = 1; i <= n; ++i) ans = Sub(ans + 1, qpow(2, a[i]));
  ans = Add(ans, qpow(2, n - 1) - 1);
  printf("%d\n", ans);
  return 0;
}
