#include <bits/stdc++.h>
using namespace std;
const long long mo = 1000000007;
int a[505], cnt[505], P[505], n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    if (a[i] != -1) cnt[a[i]]++;
  }
  P[0] = 0;
  for (int i = 1; i <= n; i++) P[i] = (P[i - 1] * 2 + 1) % mo;
  int ans = P[n - 1];
  for (int i = 1; i <= n; i++)
    if (a[i] == -1) ans = (ans + mo - P[cnt[i]]) % mo;
  printf("%d", ans);
}
