// Its just opening , middle game and end game 
#include<bits/stdc++.h>
using namespace std ; 
#define F first 
#define S second 

int MOD = 998244353 ; 
int mod = 1e9 + 7 ; 
int inf = 1e9 ; 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<int> a(2005) ; 
vector<int> all_divisors ; 
signed main() 
{
    // OPENING 

    ios_base::sync_with_stdio(false) ; 
    cin.tie(0) ; cout.tie(0) ; 
    
    int n ; 
    cin >> n ; 
    int mn = inf ; 
    for( int i = 0 ; i < n ; i++ ) 
        cin >> a[i] , mn = min( mn , a[i] ) ; ;  
 //   sort( a , a + n ) ; 
    // MIDDLE GAME 

    for( int i = 0 ; i < n ; i++ ){
        for( int j = 2 ; j*j <= a[i] ; j++ ){
            if( a[i] % j == 0 ){
                all_divisors.push_back(j) ; 
                all_divisors.push_back(a[i]/j) ; 
            }
        }
    }
    sort( all_divisors.begin() , all_divisors.end() ) ; 
    auto it = unique( all_divisors.begin() , all_divisors.end() ) ;
    all_divisors.resize( distance( all_divisors.begin() , it ) ) ;  
    all_divisors.emplace_back(1) ; 

    // END GAME 

    int ans = 0 , one = 1 ; 
    for( auto divisor : all_divisors ){
        int g = 0 ; 
        if( divisor >= mn ) 
            continue ; 
        for( int i = 0 ; i < n ; i++ ){
            if( a[i]%divisor ) 
                continue ; 
            g = __gcd( g , a[i] ) ; 
            if( g == divisor ){
                ans++ ; 
                break ; 
            }
        }
    }
    cout << ans + 1 ; 

    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}
#include <bits/stdc++.h>
//#include <atcoder/lazysegtree>
//#include <atcoder/segtree>
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)

#define rrep(i,a,n) for (int i=n-1;i>=a;i--)
#define ALL(x) x.begin(),x.end()

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pause "read -p 'Press Enter to continue...' var"

using namespace std;
//using namespace atcoder;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

/*
テスト通りますように
　　●
　　/⌒ヽ
　 ｜ 　|/⌒ヽ(ヽ
　 (｀　∥ー⌒) |
　|￣||￣￣￣￣￣|
　|―||―――――|
　|　Ｕ　　　　　|
　|￣￣￣￣￣￣￣|
　|＿＿＿＿＿＿＿|
　　|―――――|
　　|―――――|
ｗｗＷｗｗＷｗＷＷｗ
*/

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const ll INF = numeric_limits<ll>::max()/4;
const ll MAX = 100005;
const int MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  ll n;
  cin >> n;
  double L[2005],R[2005];
  rep(n){
    ll t;
    double l,r;
    cin >> t >> l >> r;
    if(t == 1){
      L[i] = l;
      R[i] = r;
    }
    if(t == 2){
      L[i] = l;
      R[i] = r-0.5;
    }
    if(t == 3){
      L[i] = l+0.5;
      R[i] = r;
    }
    if(t == 4){
      L[i] = l+0.5;
      R[i] = r-0.5;
    }
  }
  ll ans = 0;
  rep(n){
    rep(j,i+1,n){
      if(L[i] <= R[j] && R[i] >= L[j]) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
