#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

bool isValidBatch(int n, int labels[]) {
    // Check if every label from 1 to n is used exactly once
    int count[n + 1];
    for (int i = 0; i <= n; i++) {
        count[i] = 0;
    }
    
    for (int i = 0; i < n; i++) {
        if (labels[i] < 1 || labels[i] > n) {
            return false; // Invalid input: label out of range
        }
        count[labels[i]]++;
    }
    
    for (int i = 1; i <= n; i++) {
        if (count[i] != 1) {
            return false; // Batch doesn't satisfy labeling rules
        }
    }
    
    return true; // Batch satisfies labeling rules
}

int main() {
    int n;
    if (scanf("%d", &n) != 1 || n <= 0) {
        printf("Invalid input\n");
        return 1;
    }
    
    int* labels = (int*)malloc(n * sizeof(int));
    if (!labels) {
        printf("Memory allocation failed\n");
        return 1;
    }
    
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (scanf("%d", &labels[i]) != 1) {
            printf("Invalid input\n");
            free(labels);
            return 1;
        }
        count++;
    }
    
    if (count != n) {
        printf("Invalid input\n");
        free(labels);
        return 1;