#include <bits/stdc++.h>
using namespace std;
const int p = 1e9 + 7;
inline int read() {
  int neg = 1, num = 0;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') neg = -1;
  for (; isdigit(c); c = getchar()) num = (num << 1) + (num << 3) + c - '0';
  return neg * num;
}
int n, cnt[200010];
inline int Pow(int x, int y) {
  int res = 1;
  for (; y; y >>= 1, x = 1ll * x * x % p)
    if (y & 1) res = 1ll * res * x % p;
  return res;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    int a = read();
    if (a != -1) cnt[a]++;
  }
  int sum = 0;
  for (int i = 1; i <= n; i++) sum = (sum + Pow(2, cnt[i]) - 1) % p;
  sum = Pow(2, n - 1) - 1 - sum;
  sum = (sum % p + p) % p;
  cout << sum;
  return 0;
}
