#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"
template<class T> void chmax(T &a, const T b){ a = max(a, b); }
template<class T> void chmin(T &a, const T b){ a = min(a, b); }
long long gcd(long long a, long long b) { return (a % b) ? gcd(b, a % b) : b; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

template<typename T>
vector<T> get_divisor(T n) {
    vector<T> res;
    for (long long i = 1; (i * i) <= n; i++) {
        if (n % i != 0) continue;
        res.push_back(i);
        if ((i * i) != n) res.push_back(n / i);
    }
    sort(res.begin(), res.end());
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n;
    cin >> n;
    auto div = get_divisor(2 * n);
    ll ans = 0;
    for(auto x : div) {
        if ((x + 1) % 2 == 0) {
            ans++;
        }
    }
    cout << (ans * 2) << endl;
    return 0;
}

#include<bits/stdc++.h>
#define fi                first
#define se                 second
#define ll               long long
#define mod              1000000007LL
#define endl              "\n"
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb                push_back
#define all(v)             v.begin(),v.end()
#define inp(V,n)      for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)     {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define pll              pair<long long,long long>
using namespace std;
//queue<ll> q;
ll cnt=0;
//vector<ll> adj[3000005];
//vector<ll> a(1000005),b(100005);
//vector<bool> vis(3000005,false);
//ll ed,ve;
ll timer =0;
vector<pll> vp;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<ll,ll> &a,
              const pair<ll,ll> &b)
{
        return (a.fi>b.fi);
}
ll Powb(ll b,ll n)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2);
    if(n%2==0){return (temp*temp)%mod;}
    else{return (b*((temp*temp)%mod))%mod;}
}
/*ll  dfs(ll node)
{
   vis[node]=true;
   ll c=1;
   //ll c=adj[node].size();
   for(auto x:adj[node])
   {
       if(vis[x]==false)
       {
           c+=dfs(x);
       }
   }
   a[node]=c;
   return c;
}
void bfs(ll node)
{
    vis[node]=true;
    for(auto x:adj[node])
    {
        if(vis[x]==false)
        {
            bfs(x);
        }
    }
}*/
int main()
{
 fast;
     int t=1;
     //cin>>t;
     while(t--)
     {
      ll n,k,i,j,maxi=0,sum=0,c=0,d=0,e=0,f=0,g=0,h=0;
      cin>>n;
      set<ll> s;
      for(i=0;i<n;i++)
      {
          cin>>c;
          s.insert(c);
      }
      while(s.size()!=1)
      {
          auto it=s.begin(),it1=s.end();
          it1--;
          c=*it1;
          d=*it;
          s.erase(c);
          s.insert(c-d);
      }
      auto it=s.begin();
      c=*it;
      cout<<c<<endl;


     }
}
