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

    bool g(int *t, int n)
    {
    	if ( n == 0 )
    	   return false;
    	std::sort(t, t + n);
    	return (t[0] == 1) &&
				(std::distance(t, std::unique(t, t + n)) == n) &&
          		(std::accumulate(t, t + n, 0) == (n * (n + 1)) / 2);
    }

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