GCD of n numbers

According to an online judge, the limit has been exceeded. Could someone help me optimize my solution for the Greatest Common Divisor of n numbers:

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

int main() {
    int n;
    cin >> n;
    int a(n);
    for(int i = 0; i < n; i++){
        cin >> a(i);
    }
    int t = a(0);
    for(int i = 1; i < n; i++){
        t = __gcd(t, a(i));
        if(t == 1){
            break;
        }
    }
    cout << t;
}