#include <iostream>
#include <iomanip>
#include <cmath>

bool g( const int a[], int n )
{
    int long long sum = 0;
    int i = 0;
    long long int target = (1<<n)-1;

    for ( ; i < n && a[i] > 0 ; i++ ) sum += 1<<a[i]-1;

    return i == n && sum == target;
}   

int main() 
{
    const int N = 6;        
    int t[N] = { 6, 2, 3, 4, 5, 1 }; 

    std::cout << std::boolalpha << g( t, N ) << std::endl;
}
