#include <bits/stdc++.h>
using namespace std;
int sz[100100], n, ans = 0;
int qpow(int a, int b) {
  int ans = 1;
  for (; b; b >>= 1, a = 1ll * a * a % 1000000007)
    if (b & 1) ans = 1ll * ans * a % 1000000007;
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1, x; i <= n; ++i) {
    scanf("%d", &x);
    if (x != -1) sz[x]++;
  }
  for (int i = 1; i <= n; ++i) ans = (ans + qpow(2, sz[i]) - 1) % 1000000007;
  ans = (qpow(2, n - 1) - 1 - ans) % 1000000007;
  ans = (ans % 1000000007 + 1000000007) % 1000000007;
  printf("%d", ans);
}
