#include <bits/stdc++.h>
using namespace std;
long long n, a[2000005], num[2000005], ans;
long long ksm(long long x, long long y) {
  long long ans = 1, t = x;
  while (y) {
    if (y & 1) ans = ans * t % 1000000007;
    t = t * t % 1000000007;
    y >>= 1;
  }
  return ans;
}
int main() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%lld", &a[i]);
    if (a[i] != -1) num[a[i]]++;
  }
  for (long long i = 1; i <= n; i++) {
    if (a[i] == -1) ans = (ans + ksm(2, num[i]) - 1 + 1000000007) % 1000000007;
  }
  printf("%lld", (ksm(2, n - 1) - 1 - ans + 1000000007) % 1000000007);
}
