#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar()) {
    if (ch == '-') f = -1;
  }
  for (; isdigit(ch); ch = getchar()) {
    x = x * 10 + ch - 48;
  }
  return x * f;
}
const int mxN = 500;
const int P = 1e9 + 7;
int cnt[mxN + 3];
int n;
long long quickpow(long long x, long long y) {
  long long cur = x, ret = 1ll;
  for (int i = 0; y; i++) {
    if (y & (1ll << i)) {
      y -= (1ll << i);
      ret = ret * cur % P;
    }
    cur = cur * cur % P;
  }
  return ret;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    int x = read();
    if (x != -1) {
      cnt[x]++;
    }
  }
  long long ans = quickpow(2ll, n - 1) - 1;
  for (int i = 1; i <= n; i++) {
    ans = (ans - quickpow(2ll, cnt[i]) + 1 + P) % P;
  }
  printf("%I64d\n", ans);
  return 0;
}
