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