#include<stdio.h>                                                                                                                                                                     
                                                                                                                                                                                      
int main(){                                                                                                                                                                           
    int N;                                                                                                                                                                            
                                                                                                                                                                                      
    scanf("%d", &N);                                                                                                                                                                  
                                                                                                                                                                                      
    int decimal[N];                                                                                                                                                                   
    int binary[N];                                                                                                                                                                    
    for(int i = 0; i < N; i++){                                                                                                                                                       
        binary[i] = 0;                                                                                                                                                                
        printf("%d's decimal : ", i);                                                                                                                                                 
        scanf("%d", &decimal[i]);                                                                                                                                                     
        for(int base = 1; decimal[i] != 0; base = base*10){                                                                                                                           
            binary[i] = binary[i] + (decimal[i] % 2) * base;                                                                                                                          
            decimal[i] = decimal[i] /2;                                                                                                                                               
        }                                                                                                                                                                             
    }                                                                                                                                                                                 
                                                                                                                                                                                      
    int result = 0;                                                                                                                                                                   
    for(int j = 0; j < N; j++){                                                                                                                                                       
        int left;                                                                                                                                                                     
        int right;                                                                                                                                                                    
        if(j == 0){                                                                                                                                                                   
            right = binary[N-1];                                                                                                                                                      
            left = binary[j + 1];                                                                                                                                                     
        }else if(j == N-1){                                                                                                                                                           
            left = binary[j -1];                                                                                                                                                      
            right = binary[0];                                                                                                                                                        
        }else{                                                                                                                                                                        
            left = binary[j + 1];                                                                                                                                                     
            right = binary[j - 1];                                                                                                                                                    
        }                                                                                                                                                                             
        printf("left : %d  right : %d\n", left, right);                                                                                                                               
        if(left < right){                                                                                                                                                             
           int stock = left;                                                                                                                                                          
           left = right;                                                                                                                                                              
           right = stock;                                                                                                                                                             
        }                                                                                                                                                                             
                                                                                                                                                                                      
        int check = binary[j];                                                                                                                                                        
        int xor = 0;                                                                                                                                                                  
        for(int base = 1; check != 0 && left != 0 ; base = base*10){                                                                                                                  
            int big = left % 10;                                                                                                                                                      
            int small = right % 10;                                                                                                                                                   
            if(big == small){                                                                                                                                                         
                xor = xor + 0 * base;                                                                                                                                                 
            }else{                                                                                                                                                                    
                xor = xor + 1 * base;                                                                                                                                                 
            }                                                                                                                                                                         
            left = left / 10;                                                                                                                                                         
            right = right / 10;                                                                                                                                                       
            check = check / 10;                                                                                                                                                       
        }                                                                                                                                                                             
                                                                                                                                                                                      
                                                                                                                                                                                      
        printf("xor : %d  binary : %d\n", xor, binary[j]);                                                                                                                            
        if(xor == binary[j]){                                                                                                                                                         
            result ++;                                                                                                                                                                
        }                                                                                                                                                                             
    }                                                                                                                                                                                 
                                                                                                                                                                                      
    if(result == N){                                                                                                                                                                  
        printf("Yes");                                                                                                                                                                
    }else{                                                                                                                                                                            
        printf("No");                                                                                                                                                                 
    }                                                                                                                                                                                 
                                                                                                                                                                                      
    return 0;                                                                                                                                                                         
}         