#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

bool g(int *t, int n)
{
    if ( n == 0 ) 
       return false;
    std::sort(t, t + n);
    return (t[0] == 1) &&  // first number must be 1
            (t[n-1] == n) && // last must be n
            (std::set<int>(t, t+n).size() == n); // all must be unique
}

int main()
{
   int arr[] = {1,2,3,4,5,6,7};
   std::cout << g(arr, 7);
}