結果
| 問題 | 
                            No.1237 EXP Multiple!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-09-25 23:46:57 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 99 ms / 2,000 ms | 
| コード長 | 409 bytes | 
| コンパイル時間 | 155 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 105,728 KB | 
| 最終ジャッジ日時 | 2024-06-28 08:40:51 | 
| 合計ジャッジ時間 | 2,569 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 19 | 
ソースコード
mod=10**9+7
n=int(input())
arr=list(map(int,input().split()))
if arr.count(0)!=0:
    print(-1)
elif arr.count(1)+arr.count(2)+arr.count(3)!=n:
    print(mod)
else:
    ans=1
    for val in arr:
        if val==1:
            ans*=1
        elif val==2:
            ans*=4
        elif val==3:
            ans*=729
        if ans>mod:
            print(mod)
            break
    else:
        print(mod%ans)