#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
//#pragma GCC target("avx2")

#define deb(x) cout << #x << " = " << x << "\n"
#define all(x) (x).begin(), (x).end()
#define len(x) (ll) x.size()
#define lsb(x) (x) & -(x)
#define l(x) (x << 1) + 1
#define r(x) (x << 1) + 2
#define v(x) (ll)(x - 'a')

#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
typedef pair <ld, ld> pld;
typedef pair <ll, ll> pll;

template <class T1, class T2 = less <T1>> using pb_heap = __gnu_pbds::priority_queue <T1, T2, binary_heap_tag>;
template <class T1, class T2 = null_type, class T3 = less <T1>> using pb_map = tree <T1, T2, T3, rb_tree_tag, tree_order_statistics_node_update>;
template <class T1, class T2 = null_type, class T3 = hash <T1>> using pb_umap = gp_hash_table <T1, T2, T3>;
template <class T1, class T2, class T3 = hash <T1>> using umap = unordered_map <T1, T2, T3>;
template <class T> using uset = unordered_set <T>;
template <class T> using vec = vector <T>;

const ll infll = numeric_limits <ll>::max() >> 1;
const ll inf = numeric_limits <ll>::max() >> 1;
const ll N = 1e5 + 1;
ll m, n, d;
ll arr[N];
ll inv[N];

set <ll> elem;
set <ll> inve;

void input() {
    cin >> m >> n;
    for(ll i = 1; i <= n; ++i) {
        cin >> arr[i];
        elem.insert(arr[i]);
    }
}

ll fpow(ll b, ll p = m - 2) {
    ll res = 1;
    ll pow = b;
    for(; p; p >>= 1) {
        if(p & 1) {
            res *= pow;
            res %= m;
        }
        pow *= pow;
        pow %= m;
    }
    return res;
}

ll compute() {
    ll x = arr[1];
    ll y = arr[2];
    ll dif = x - y;
    if(dif < 0) {
        dif += m;
    }
    ll cnt = 0;
    for(ll i = 1; i <= n; ++i) {
        cnt += elem.count((arr[i] + dif) % m);
    }
    ll k = n - cnt;
    return 1ll * dif * fpow(k) % m;
}

ll compute_inv() {
    ll len = 0;
    for(ll i = 0; i < m; ++i) {
        if(!elem.count(i)) {
            inve.insert(i);
            inv[++len] = i;
        }
    }
    if(len == 1) {
        cout << (inv[1] + 1) % m << " " << 1 << "\n";
        exit(0);
    }
    ll x = inv[1];
    ll y = inv[2];
    ll dif = x - y;
    if(dif < 0) {
        dif += m;
    }
    ll cnt = 0;
    for(ll i = 1; i <= len; ++i) {
        cnt += inve.count((inv[i] + dif) % m);
    }
    ll k = len - cnt;
    return 1ll * dif * fpow(k) % m;
}

bool test(ll x, ll d) {
    ll res = 0;
    for(ll i = 0; i < n; ++i) {
        res += elem.count((x + i * d) % m);
    }
    return res == n;
}

void solve() {
    if(n == 1) {
        cout << arr[1] << " " << 0 << "\n";
        return;
    }
    if(n * 2 < m) {
        d = compute();
    } else {
        d = compute_inv();
    }
    for(ll i = 1; i <= n; ++i) {
        if(!elem.count((arr[i] - d + m) % m)) {
            if(test(arr[i], d)) {
                cout << arr[i] << " " << d << "\n";
            } else {
                cout << "-1\n";
            }
            return;
        }
    }
    cout << "-1\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    input();
    solve();
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
//#pragma GCC target("avx2")

#define deb(x) cout << #x << " = " << x << "\n"
#define all(x) (x).begin(), (x).end()
#define len(x) (ll) x.size()
#define lsb(x) (x) & -(x)
#define l(x) (x << 1) + 1
#define r(x) (x << 1) + 2
#define v(x) (ll)(x - 'a')

#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;
typedef pair <ld, ld> pld;
typedef pair <ll, ll> pll;

template <class T1, class T2 = less <T1>> using pb_heap = __gnu_pbds::priority_queue <T1, T2, binary_heap_tag>;
template <class T1, class T2 = null_type, class T3 = less <T1>> using pb_map = tree <T1, T2, T3, rb_tree_tag, tree_order_statistics_node_update>;
template <class T1, class T2 = null_type, class T3 = hash <T1>> using pb_umap = gp_hash_table <T1, T2, T3>;
template <class T1, class T2, class T3 = hash <T1>> using umap = unordered_map <T1, T2, T3>;
template <class T> using uset = unordered_set <T>;
template <class T> using vec = vector <T>;

const ll infll = numeric_limits <ll>::max() >> 1;
const ll inf = numeric_limits <ll>::max() >> 1;
const ll N = 1e5 + 1;
ll m, n, d;
ll arr[N];
ll inv[N];

set <ll> elem;
set <ll> inve;

void input() {
    cin >> m >> n;
    for(ll i = 1; i <= n; ++i) {
        cin >> arr[i];
        elem.insert(arr[i]);
    }
}

ll fpow(ll b, ll p = m - 2) {
    ll res = 1;
    ll pow = b;
    for(; p; p >>= 1) {
        if(p & 1) {
            res *= pow;
            res %= m;
        }
        pow *= pow;
        pow %= m;
    }
    return res;
}

ll compute() {
    ll x = arr[1];
    ll y = arr[2];
    ll dif = x - y;
    if(dif < 0) {
        dif += m;
    }
    ll cnt = 0;
    for(ll i = 1; i <= n; ++i) {
        cnt += elem.count((arr[i] + dif) % m);
    }
    ll k = n - cnt;
    return 1ll * dif * fpow(k) % m;
}

ll compute_inv() {
    ll len = 0;
    for(ll i = 0; i < m; ++i) {
        if(!elem.count(i)) {
            inve.insert(i);
            inv[++len] = i;
        }
    }
    if(len == 1) {
        cout << (inv[1] + 1) % m << " " << 1 << "\n";
        exit(0);
    }
    ll x = inv[1];
    ll y = inv[2];
    ll dif = x - y;
    if(dif < 0) {
        dif += m;
    }
    ll cnt = 0;
    for(ll i = 1; i <= len; ++i) {
        cnt += inve.count((inv[i] + dif) % m);
    }
    ll k = len - cnt;
    return 1ll * dif * fpow(k) % m;
}

bool test(ll x, ll d) {
    ll res = 0;
    for(ll i = 0; i < n; ++i) {
        res += elem.count((x + i * d) % m);
    }
    return res == n;
}

void solve() {
    if(n == m) {
        cout << "0 1\n";
        return;
    }
    if(n == 1) {
        cout << arr[1] << " " << 0 << "\n";
        return;
    }
    if(n * 2 < m) {
        d = compute();
    } else {
        d = compute_inv();
    }
    for(ll i = 1; i <= n; ++i) {
        if(!elem.count((arr[i] - d + m) % m)) {
            if(test(arr[i], d)) {
                cout << arr[i] << " " << d << "\n";
            } else {
                cout << "-1\n";
            }
            return;
        }
    }
    cout << "-1\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    input();
    solve();
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
//#pragma GCC target("avx2")

#define deb(x) cout << #x << " = " << x << "\n"
#define all(x) (x).begin(), (x).end()
#define len(x) (int) x.size()
#define lsb(x) (x) & -(x)
#define l(x) (x << 1) + 1
#define r(x) (x << 1) + 2
#define v(x) (int)(x - 'a')

#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ld, ld> pld;
typedef pair <ll, ll> pll;

template <class T1, class T2 = less <T1>> using pb_heap = __gnu_pbds::priority_queue <T1, T2, binary_heap_tag>;
template <class T1, class T2 = null_type, class T3 = less <T1>> using pb_map = tree <T1, T2, T3, rb_tree_tag, tree_order_statistics_node_update>;
template <class T1, class T2 = null_type, class T3 = hash <T1>> using pb_umap = gp_hash_table <T1, T2, T3>;
template <class T1, class T2, class T3 = hash <T1>> using umap = unordered_map <T1, T2, T3>;
template <class T> using uset = unordered_set <T>;
template <class T> using vec = vector <T>;

const ll infll = numeric_limits <ll>::max() >> 1;
const int inf = numeric_limits <int>::max() >> 1;
const int N = 1e5 + 1;
int m, n, d;
int arr[N];
int inv[N];

set <int> elem;
set <int> inve;

void input() {
    cin >> m >> n;
    for(int i = 1; i <= n; ++i) {
        cin >> arr[i];
        elem.insert(arr[i]);
    }
}

int fpow(int b, int p = m - 2) {
    ll res = 1;
    ll pow = b;
    for(; p; p >>= 1) {
        if(p & 1) {
            res *= pow;
            res %= m;
        }
        pow *= pow;
        pow %= m;
    }
    return res;
}

int compute() {
    int x = arr[1];
    int y = arr[2];
    int dif = x - y;
    if(dif < 0) {
        dif += m;
    }
    int cnt = 0;
    for(int i = 1; i <= n; ++i) {
        cnt += elem.count((arr[i] + dif) % m);
    }
    int k = n - cnt;
    return 1ll * dif * fpow(k) % m;
}

int compute_inv() {
    int len = 0;
    for(int i = 0; i < m; ++i) {
        if(!elem.count(i)) {
            inve.insert(i);
            inv[++len] = i;
        }
    }
    if(len == 1) {
        cout << (inv[1] + 1) % m << " " << 1 << "\n";
        exit(0);
    }
    int x = inv[1];
    int y = inv[2];
    int dif = x - y;
    if(dif < 0) {
        dif += m;
    }
    int cnt = 0;
    for(int i = 1; i <= len; ++i) {
        cnt += inve.count((inv[i] + dif) % m);
    }
    int k = len - cnt;
    return 1ll * dif * fpow(k) % m;
}

bool test(int x, int d) {
    int res = 0;
    for(int i = 0; i < n; ++i) {
        res += elem.count((x + i * d) % m);
    }
    return res == n;
}

void solve() {
    if(n == 1) {
        cout << arr[1] << " " << 0 << "\n";
        return;
    }
    if(n * 2 < m) {
        d = compute();
    } else {
        d = compute_inv();
    }
    for(int i = 1; i <= n; ++i) {
        if(!elem.count((arr[i] - d + m) % m)) {
            if(test(arr[i], d)) {
                cout << arr[i] << " " << d << "\n";
            } else {
                cout << "-1\n";
            }
            return;
        }
    }
    cout << "-1\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    input();
    solve();
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>

#pragma 03

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define gcd __gcd
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i=0; i<(n); i++)
#define rep1(i, n) for (int i=1; i<=(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
template<typename _def> using ordered_set=tree<_def, null_type, less<_def>, rb_tree_tag, tree_order_statistics_node_update>;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;

ll m; int n;
constexpr int N=1e5;
ll a[N];
ll sum, sq;

inline ll add(ll a, ll b) {return (a+b)%m;}
inline ll sub(ll a, ll b) {return add(a, m-b);}
inline ll mul(ll a, ll b) {return (a*b)%m;}

ll exp(ll a, ll b, ll p=m) {
    if(!b) return 1;
    else {
        ll x=exp(a, b/2);
        x=x*x%p;
        if(b&1) return x*a%p;
        else return x;
    }
}

inline ll inv(ll a) {return exp(a, m-2);}

unordered_set<ll> allowed;
inline ll calc_square_d(ll x) {
    ll c1=mul(2, mul(x, sum));
    ll c2=mul(n, mul(x, x));
    ll lf=add(sub(sq, c1), c2);
    ll rg=mul(6, inv(mul(n, mul(n-1, 2*n-1))));
    return mul(lf, rg);
}

inline ll legendre(ll x) {
    ll ls=exp(x, (m-1)/2);
    if(ls==m-1) return -1;
    else return ls;
}

pll tonelli_shanks(ll a) {
    if(a==0) return {0, -1};
    if(m==2) return {a, -1};
    if(legendre(a)!=1) return {-1, -1};
    if(m%4==3) {
        ll x=exp(a, (m+1)/4);
        return {x, m-x};
    }
    ll q=m-1, s=0;
    while(q%2==0) s++, q/=2;
    ll z=1;
    while(legendre(z)!=-1) z++;
    ll c=exp(z, q);
    ll x=exp(a, (q+1)/2);
    ll t=exp(a, q);
    ll p=s;
    while(t!=1) {
        ll i=0, e=2;
        for(i=1; i<p; i++) {
            if(exp(t, e)==1) break;
            (e*=2)%=m-2;
        }
        ll b=exp(c, exp(2LL, p-i-1, m-2));
        x=mul(x, b);
        c=mul(b, b);
        t=mul(t, c);
        p=i;
    }
    return {x, m-x};
}

bool check(ll x, ll d) {
    unordered_set<int> lf, rg;
    rep(i, n) lf.insert(a[i]);
    rep(i, n) rg.insert(add(x, mul(i, d)));
    return lf==rg;
}

int32_t main() {
    fastio;
    cin>>m>>n;
    rep(i, n) {
        cin>>a[i];
        (sum+=a[i])%=m;
        (sq+=a[i]*a[i])%=m;
    }
    int E=0;
    if(m==2*n-1) {
        E=sub(m, n);
        unordered_set<int> has;
        rep(i, n) has.insert(a[i]);
        int k=0; sum=sq=0;
        rep(i, m) if(has.find(i)==has.end()) {
            a[k++]=i;
            (sum+=i)%=m;
            (sq+=1LL*i*i)%=m;
        }
        n=k;
    }
    rep1(i, n-1) {
        allowed.insert(sub(a[0], a[i]));
        allowed.insert(sub(a[i], a[0]));
    }
    rep(i, n) {
        ll tg=calc_square_d(a[i]);
        pll res=tonelli_shanks(tg);
        for(ll d: {res.fi, res.se}) {
            if(d==-1) continue;
            if(allowed.find(d)==allowed.end()) continue;
            if(sub(sum, mul(n, a[i]))!=mul(mul(mul(n, n-1), inv(2)), d)) continue;
            if(!check(a[i], d)) continue;
            cout<<add(mul(E, d), a[i])<<' '<<d<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>

#pragma 03

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define gcd __gcd
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i=0; i<(n); i++)
#define rep1(i, n) for (int i=1; i<=(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
template<typename _def> using ordered_set=tree<_def, null_type, less<_def>, rb_tree_tag, tree_order_statistics_node_update>;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;

ll m; int n;
constexpr int N=1e5;
ll a[N];
ll sum, sq;

inline ll add(ll a, ll b) {return (a+b)%m;}
inline ll sub(ll a, ll b) {return add(a, m-b);}
inline ll mul(ll a, ll b) {return (a*b)%m;}

ll exp(ll a, ll b, ll p=m) {
    if(!b) return 1;
    else {
        ll x=exp(a, b/2);
        x=x*x%p;
        if(b&1) return x*a%p;
        else return x;
    }
}

inline ll inv(ll a) {return exp(a, m-2);}

unordered_set<ll> allowed;
inline ll calc_square_d(ll x) {
    ll c1=mul(2, mul(x, sum));
    ll c2=mul(n, mul(x, x));
    ll lf=add(sub(sq, c1), c2);
    ll rg=mul(6, inv(mul(n, mul(n-1, 2*n-1))));
    return mul(lf, rg);
}

inline ll legendre(ll x) {
    ll ls=exp(x, (m-1)/2);
    if(ls==m-1) return -1;
    else return ls;
}

pll tonelli_shanks(ll a) {
    if(a==0) return {0, -1};
    if(m==2) return {a, -1};
    if(legendre(a)!=1) return {-1, -1};
    if(m%4==3) {
        ll x=exp(a, (m+1)/4);
        return {x, m-x};
    }
    ll q=m-1, s=0;
    while(q%2==0) s++, q/=2;
    ll z=1;
    while(legendre(z)!=-1) z++;
    ll c=exp(z, q);
    ll x=exp(a, (q+1)/2);
    ll t=exp(a, q);
    ll p=s;
    while(t!=1) {
        ll i=0, e=2;
        for(i=1; i<p; i++) {
            if(exp(t, e)==1) break;
            (e*=2)%=m-2;
        }
        ll b=exp(c, exp(2LL, p-i-1, m-2));
        x=mul(x, b);
        c=mul(b, b);
        t=mul(t, c);
        p=i;
    }
    return {x, m-x};
}

bool check(ll x, ll d) {
    unordered_set<int> lf, rg;
    rep(i, n) lf.insert(a[i]);
    rep(i, n) rg.insert(add(x, mul(i, d)));
    return lf==rg;
}

int32_t main() {
    fastio;
    cin>>m>>n;
    rep(i, n) {
        cin>>a[i];
        (sum+=a[i])%=m;
        (sq+=a[i]*a[i])%=m;
    }
    if(n==1) {cout<<a[0]<<' '<<0<<endl; return 0;}
    if(n==2) {cout<<a[0]<<' '<<sub(a[1], a[0])<<endl; return 0;}
    if(n==m) {cout<<"0 1\n"; return 0;}
    int E=0;
    if(m==2*n-1) {
        E=sub(m, n);
        unordered_set<int> has;
        rep(i, n) has.insert(a[i]);
        int k=0; sum=sq=0;
        rep(i, m) if(has.find(i)==has.end()) {
            a[k++]=i;
            (sum+=i)%=m;
            (sq+=1LL*i*i)%=m;
        }
        n=k;
    }
    rep1(i, n-1) {
        allowed.insert(sub(a[0], a[i]));
        allowed.insert(sub(a[i], a[0]));
    }
    rep(i, n) {
        ll tg=calc_square_d(a[i]);
        pll res=tonelli_shanks(tg);
        for(ll d: {res.fi, res.se}) {
            if(d==-1) continue;
            if(allowed.find(d)==allowed.end()) continue;
            if(sub(sum, mul(n, a[i]))!=mul(mul(mul(n, n-1), inv(2)), d)) continue;
            if(!check(a[i], d)) continue;
            cout<<add(mul(E, d), a[i])<<' '<<d<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>

#pragma 03

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define gcd __gcd
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define rep(i, n) for (int i=0; i<(n); i++)
#define rep1(i, n) for (int i=1; i<=(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned uint;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
template<typename _def> using ordered_set=tree<_def, null_type, less<_def>, rb_tree_tag, tree_order_statistics_node_update>;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;

ll m; int n;
constexpr int N=1e5;
ll a[N];
ll sum, sq;

inline ll add(ll a, ll b) {return (a+b)%m;}
inline ll sub(ll a, ll b) {return add(a, m-b);}
inline ll mul(ll a, ll b) {return (a*b)%m;}

ll exp(ll a, ll b, ll p=m) {
    if(!b) return 1;
    else {
        ll x=exp(a, b/2);
        x=x*x%p;
        if(b&1) return x*a%p;
        else return x;
    }
}

inline ll inv(ll a) {return exp(a, m-2);}

unordered_set<ll> allowed;
inline ll calc_square_d(ll x) {
    ll c1=mul(2, mul(x, sum));
    ll c2=mul(n, mul(x, x));
    ll lf=add(sub(sq, c1), c2);
    ll rg=mul(6, inv(mul(n, mul(n-1, 2*n-1))));
    return mul(lf, rg);
}

inline ll legendre(ll x) {
    ll ls=exp(x, (m-1)/2);
    if(ls==m-1) return -1;
    else return ls;
}

pll tonelli_shanks(ll a) {
    if(a==0) return {0, -1};
    if(m==2) return {a, -1};
    if(legendre(a)!=1) return {-1, -1};
    if(m%4==3) {
        ll x=exp(a, (m+1)/4);
        return {x, m-x};
    }
    ll q=m-1, s=0;
    while(q%2==0) s++, q/=2;
    ll z=1;
    while(legendre(z)!=-1) z++;
    ll c=exp(z, q);
    ll x=exp(a, (q+1)/2);
    ll t=exp(a, q);
    ll p=s;
    while(t!=1) {
        ll i=0, e=2;
        for(i=1; i<p; i++) {
            if(exp(t, e)==1) break;
            (e*=2)%=m-2;
        }
        ll b=exp(c, exp(2LL, p-i-1, m-2));
        x=mul(x, b);
        c=mul(b, b);
        t=mul(t, c);
        p=i;
    }
    return {x, m-x};
}

bool check(ll x, ll d) {
    unordered_set<int> lf, rg;
    rep(i, n) lf.insert(a[i]);
    rep(i, n) rg.insert(add(x, mul(i, d)));
    return lf==rg;
}

int32_t main() {
    fastio;
    cin>>m>>n;
    rep(i, n) {
        cin>>a[i];
        (sum+=a[i])%=m;
        (sq+=a[i]*a[i])%=m;
    }
    if(n==1) {cout<<a[0]<<' '<<0<<endl; return 0;}
    if(n==2) {cout<<a[0]<<' '<<sub(a[1], a[0])<<endl; return 0;}
    int E=0;
    if(m==2*n-1) {
        E=sub(m, n);
        unordered_set<int> has;
        rep(i, n) has.insert(a[i]);
        int k=0; sum=sq=0;
        rep(i, m) if(has.find(i)==has.end()) {
            a[k++]=i;
            (sum+=i)%=m;
            (sq+=1LL*i*i)%=m;
        }
        n=k;
    }
    rep1(i, n-1) {
        allowed.insert(sub(a[0], a[i]));
        allowed.insert(sub(a[i], a[0]));
    }
    rep(i, n) {
        ll tg=calc_square_d(a[i]);
        pll res=tonelli_shanks(tg);
        for(ll d: {res.fi, res.se}) {
            if(d==-1) continue;
            if(allowed.find(d)==allowed.end()) continue;
            if(sub(sum, mul(n, a[i]))!=mul(mul(mul(n, n-1), inv(2)), d)) continue;
            if(!check(a[i], d)) continue;
            cout<<add(mul(E, d), a[i])<<' '<<d<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
#define mem(a, b) memset(a,b,sizeof(a))
#define rep(i, a, b) for(int i=a;i<b;i++)
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 10;

int n;
int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt","w",stdout);
#endif
    while(scanf("%d",&n)!=EOF){
        ll ret=0;
        vector<int> li;
        rep(i,0,n){
            int t; scanf("%d",&t);
            li.push_back(t);
        }
        int cur=0;
        int res=0;

        while(!li.empty()){
            int flag=0;
            ll height=li.back()-cur;
            ll tmp=((ll)li.size())*height;
            //cout<<"-- "<<height<<" "<<res<<endl;
            if(tmp&1){
                if(res==1) ret++,res=0;
                else res=1;
            }else {
                if(height&1){
                    res=0;
                    flag=-1;
                }else {

                }
            }
            ret+=tmp/2;
            cur=li.back();
            while(li.back()==cur) li.pop_back();
            int tt=li.back(); tt+=flag;
            li.pop_back();
            if(tt){
                li.push_back(tt);
                if(flag==-1) cur--;
            }
        }
        cout<<ret<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long int n,a,cp=0,ci=0,sum[2]={0};
    cin>>n;
    for(long long int i=0;i<n;i++)
    {
        cin>>a;
        sum[i&1]+=a/2;
		sum[(i+1)&1]+=a-a/2;
    }
    cout<<min(sum[0],sum[1])<<endl;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,a,cp=0,ci=0,sum[2]={0};
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        sum[i&1]+=a/2;
		sum[(i+1)&1]+=a-a/2;
    }
    cout<<min(sum[0],sum[1])<<endl;
}


    #include <bits/stdc++.h>

    using namespace std;

    int main()
    {
        long long int n,a,cp=0,ci=0;
        cin>>n;
        for(long long int i=0;i<n;i++)
        {
            cin>>a;
            if(i%2==0)
            {
                if(a%2==0)
                {
                    cp+=a/2;
                    ci+=a/2;
                }
                else
                {
                    ci+=a/2;
                    cp+=(a-(a/2));
                }
            }
            else
            {
                if(a%2==0)
                {
                    cp+=a/2;
                    ci+=a/2;
                }
                else
                {
                    cp+=a/2;
                    ci+=(a-(a/2));
                }
            }
        }
        cout<<min(cp,ci)<<endl;
    }


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,a,cp=0,ci=0;
    cin>>n;
    vector<vector<int> > v(n);
    cin>>a;
    v[0]=vector<int>(a);
    for(int i=1;i<n;i++)
    {
        cin>>a;
        v[i]=vector<int>(a,0);
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<v[i].size();j++)
        {
            if((i+j)%2==0)
                cp++;
            else
                ci++;
        }
    }
    cout<<min(cp,ci)<<endl;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,a,cp=0,ci=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a;
        if(i%2==0)
        {
            if(a%2==0)
            {
                cp+=a/2;
                ci+=a/2;
            }
            else
            {
                ci+=a/2;
                cp+=(a-(a/2));
            }
        }
        else
        {
            if(a%2==0)
            {
                cp+=a/2;
                ci+=a/2;
            }
            else
            {
                cp+=a/2;
                ci+=(a-(a/2));
            }
        }
    }
    cout<<min(cp,ci)<<endl;
}


#include<bits/stdc++.h>
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
typedef long long ll;
#define max_ll 0x6fffffffffffffff
using namespace std;
ll n;
int a[300003];ll ans=0;
int solve(int c)
{
    int l=c,r=n,mid;
    while(l<r)
    {
        mid=r-(r-l)/2;
        if(a[mid]>=c)l=mid;
        else r=mid-1;
    }
    ll k=l-c+a[c]-c+1;
    k=max(0ll,k);
    ans+=k/2;
}
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;

	for(int i=1;i<=n;i++)cin>>a[i],ans+=a[i]/2,a[i]%=2;
	for(int i=1;i<=n;i++)
    {
        solve(i);
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
typedef long long ll;
#define max_ll 0x6fffffffffffffff
using namespace std;
ll n;
int a[300003];ll ans=0;
int solve(int c)
{
    int l=c,r=n,mid;
    while(l<r)
    {
        mid=r-(r-l)/2;
        if(a[mid]>=c)l=mid;
        else r=mid-1;
    }
    ll k=l-c+a[c]-c+1;
    k=max(0ll,k);
    ans+=k/2;
    return 0;
}
int solve2(int i)
{
    for(;i<=n;i++)if(a[i])break;
    return i;
}
int parity[2];
map<int,int> ch;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;

	for(int i=1;i<=n;i++)cin>>a[i],ans+=a[i]/2,a[i]%=2;
	for(int i=1;i<=n;i++)
    {
        if(!a[i])continue;
        parity[i&1]++;
    }
    ans+=parity[0]/2;
    ans+=parity[1]/2;
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
typedef long long ll;
#define max_ll 0x6fffffffffffffff
using namespace std;
ll n;
int a[300003];ll ans=0;
int solve(int c)
{
    int l=c,r=n,mid;
    while(l<r)
    {
        mid=r-(r-l)/2;
        if(a[mid]>=c)l=mid;
        else r=mid-1;
    }
    ll k=l-c+a[c]-c+1;
    k=max(0ll,k);
    ans+=k/2;
    return 0;
}
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;

	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)
    {
        solve(i);
    }
    cout<<ans;
    return 0;
}


#include<bits/stdc++.h>
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
typedef long long ll;
#define max_ll 0x6fffffffffffffff
using namespace std;
ll n;
int a[300003];ll ans=0;
int solve(int c)
{
    int l=c,r=n,mid;
    while(l<r)
    {
        mid=r-(r-l)/2;
        if(a[mid]>=c)l=mid;
        else r=mid-1;
    }
    ll k=l-c+a[c]-c+1;
    k=max(0ll,k);
    ans+=k/2;
    return 0;
}
int solve2(int i)
{
    for(;i<=n;i++)if(a[i])break;
    return i;
}
int parity[2];
map<int,int> ch;
int main()
{
	ios::sync_with_stdio(0);
	cin>>n;

	for(int i=1;i<=n;i++)cin>>a[i],ans+=a[i]/2,a[i]%=2;
	for(int i=1;i<=n;i++)
    {
        if(!a[i])continue;
        parity[i&1]++;
    }
    ans+=min(parity[0],parity[1]);
    cout<<ans;
    return 0;
}


#include<iostream>
using namespace std;
int32_t main()
{
    int n;
    cin>>n;
    int a=0,b=0,x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x%2==0)
        {
            a+=(x/2);
            b+=(x+1)/2;
        }
        else
        {
            a+=(x+1)/2;
            b+=(x)/2;

        }

    }
    cout<<std::min(a,b)<<endl;
    return 0;
}


#include<iostream>
using namespace std;
int32_t main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x%2==0)
        {
            a+=(x/2);
            b+=(x+1)/2;
        }
        else
        {
            a+=(x+1)/2;
            b+=(x)/2;

        }

    }
    cout<<a<<" "<<b<<endl;
    return 0;
}


#include<iostream>
using namespace std;
int32_t main()
{
    int n;
    cin>>n;
    int a=0,b=0,x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(i%2==0)
        {
            a+=(x/2);
            b+=(x+1)/2;
        }
        else
        {
            a+=(x+1)/2;
            b+=(x)/2;

        }

    }
    cout<<std::min(a,b)<<endl;
    return 0;
}


#include<iostream>
using namespace std;
int32_t main()
{
    int n;
    cin>>n;
    int a=0,b=0;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x%2==0)
        {
            a+=(x/2);
            b+=(x+1)/2;
        }
        else
        {
            a+=(x+1)/2;
            b+=(x)/2;

        }

    }
    cout<<std::min(a,b)<<endl;
    return 0;
}


#include<iostream>

using namespace std;
#define int long long
int32_t main()
{
    int n;
    cin>>n;
    int a=0,b=0,x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(i%2==0)
        {
            a+=(x/2);
            b+=(x+1)/2;
        }
        else
        {
            a+=(x+1)/2;
            b+=(x)/2;

        }

    }
    cout<<std::min(a,b)<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=300010;
int n;
int a[N];
int main()
{
    scanf("%d",&n);
    for(int k=1;k<=n;k++)
        scanf("%d",&a[k]);
    long long x=0ll,y=0ll;
    for(int k=1;k<=n;k++)
    {
        if(k&1)
        {
            x+=(a[k]+1)/2;
            y+=a[k]/2;
        }
        else
        {
            y+=(a[k]+1)/2;
            x+=a[k]/2;
        }
    }
    cout<<min(x,y)<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=300010;
int n;
int a[N];
long long ans;
int main()
{
    scanf("%d",&n);
    for(int k=1;k<=n;k++)
        scanf("%d",&a[k]),ans+=a[k]/2;
    int x=0;
    for(int k=1;k<=n;k++)
    {
        if(a[k]&1) x++;
        else
        {
            ans+=x/2;
            x=0;
        }
    }
    cout<<ans<<endl;
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=300010;
int n;
int a[N];
long long ans;
int main()
{
    scanf("%d",&n);
    for(int k=1;k<=n;k++)
        scanf("%d",&a[k]),ans+=a[k]/2;
    int x=0;
    for(int k=1;k<=n;k++)
    {
        if(a[k]&1) x++;
        else
        {
            ans+=x/2;
            x=0;
        }
    }
    ans+=x/2;
    cout<<ans<<endl;
    return 0;
}


#include <cstdio>
#define ll long long
using namespace std;
const int N = 300005;

int n;

ll ans = 0;
ll A[N];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%lld", &A[i]);
	}
	for(int i = 1; i <= n; i ++){
		if(A[i] & 1){
			if(A[i + 1] & 1){
				ans += A[i + 1];
				ans += (A[i] - A[i + 1]) / 2;
				A[i + 1] = 0;
			}
			else{
				ans += A[i] / 2;
			}
		}
		else{
			ans += A[i] / 2;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


#include <cstdio>
#define ll long long
#include <algorithm>
using namespace std;
const int N = 300015;

int n;

ll ans = 0;
ll cnt1, cnt2;
ll A[N];
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%lld", &A[i]);
		if(i & 1){
			cnt2 += A[i] / 2;
			cnt1 += A[i] - A[i] / 2;
		}
		else{
			cnt1 += A[i] / 2;
			cnt2 += A[i] - A[i] / 2;
		}
	}
	printf("%lld\n", max(cnt1, cnt2));
	return 0;
}


#include <cstdio>
#define ll long long
using namespace std;
const int N = 300005;

int n;

ll ans = 0;
ll A[N];

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%lld", &A[i]);
	}
	for(int i = 1; i <= n; i ++){
		if(A[i] & 1){
			if(A[i + 1] & 1){
				ans += A[i + 1];
				ans += (A[i] - A[i + 1]) / 2;
				A[i + 1] = 0;
			}
			else{
				ans += A[i] / 2;
			}
		}
		else{
			ans += A[i] / 2;
		}
	}
	printf("%d\n", ans);
}


#include <cstdio>
#define ll long long
#include <algorithm>
using namespace std;
const int N = 300015;

int n;

ll ans = 0;
ll cnt1, cnt2;
ll A[N];
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%lld", &A[i]);
		if(i & 1){
			cnt2 += A[i] / 2;
			cnt1 += A[i] - (A[i] / 2);
		}
		else{
			cnt1 += A[i] / 2;
			cnt2 += A[i] - (A[i] / 2);
		}
	}
	printf("%lld\n", min(cnt1, cnt2));
	return 0;
}


#include <cstdio>
#define ll long long
#include <algorithm>
using namespace std;
const int N = 300015;

int n;

ll ans1 = 0;
ll ans2 = 0;
ll A[N];
ll B[N];
ll d[N];
ll mx = 0;
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%lld", &A[i]);
		d[1] ++;
		d[A[i] + 1] --;
		mx = max(mx, A[i]);
	}
	for(int i = 1; i <= mx; i ++){
		B[i] = B[i - 1] + d[i];
	}
	for(int i = 1; i <= n; i ++){
		if(A[i] & 1){
			if(A[i + 1] & 1){
				ans1 += A[i + 1];
				ans1 += (A[i] - A[i + 1]) / 2;
				A[i + 1] = 0;
			}
			else{
				ans1 += A[i] / 2;
			}
		}
		else{
			ans1 += A[i] / 2;
		}
	}
	for(int i = 1; i <= mx; i ++){
		if(B[i] & 1){
			if(B[i + 1] & 1){
				ans2 += B[i + 1];
				ans2 += (B[i] - B[i + 1]) / 2;
				B[i + 1] = 0;
			}
			else{
				ans2 += B[i] / 2;
			}
		}
		else{
			ans2 += B[i] / 2;
		}
	}
	printf("%lld\n", max(ans1, ans2));
	return 0;
}


#include <cstdio>
#define ll long long
#include <algorithm>
using namespace std;
const int N = 300015;

int n;

ll ans = 0;
ll cnt1, cnt2;
ll A[N];
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%lld", &A[i]);
		if(i & 1){
			cnt2 += A[i] / 2;
			cnt1 += A[i] - 2 * (A[i] / 2);
		}
		else{
			cnt1 += A[i] / 2;
			cnt2 += A[i] - 2 * (A[i] / 2);
		}
	}
	printf("%lld\n", max(cnt1, cnt2));
	return 0;
}


#include <cstdio>
#define ll long long
#include <algorithm>
using namespace std;
const int N = 300015;

int n;

ll ans = 0;
ll cnt1, cnt2;
ll A[N];
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%lld", &A[i]);
		if(i & 1){
			cnt2 += A[i] / 2;
			cnt1 += A[i] - 2 * (A[i] / 2);
		}
		else{
			cnt1 += A[i] / 2;
			cnt2 += A[i] - 2 * (A[i] / 2);
		}
	}
	printf("%lld\n", min(cnt1, cnt2));
	return 0;
}


#include <cstdio>
#define ll long long
#include <algorithm>
using namespace std;
const int N = 300015;

int n;

ll ans = 0;
ll cnt1, cnt2;
ll A[N];
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i ++){
		scanf("%lld", &A[i]);
		if(i & 1){
			cnt2 += A[i] / 2;
			cnt1 += A[i] - cnt2;
		}
		else{
			cnt1 += A[i] / 2;
			cnt2 += A[i] - cnt1;
		}
	}
	printf("%lld\n", max(cnt1, cnt2));
	return 0;
}


#include<bits/stdc++.h>

typedef long long ll;
#define EPSILON 1e-6
using namespace std;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    freopen("grendizer.in", "r", stdin);
//    freopen ("myfile.txt","w",stdout);
    ll n;
    cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    ll c = 0;
    ll x = 0;
    int y = -1;
    v.push_back(0);
    for (int i = 0; i <= n; i++) {
        c += v[i] / 2;
        if (v[i] % 2) {
            x++;
        } else {
            c += x / 2;
            if (x % 2) {
                if (y == -1) {
                    y = i - 1;
                } else {
                    if ((i - y) % 2 == 0) {
                        c++;
                    }
                    y = i - 1;
                }
            }
            x = 0;
        }
    }
//    c += x / 2;
    cout << c << endl;

    return 0;
}


#include<bits/stdc++.h>

typedef long long ll;
#define EPSILON 1e-6
using namespace std;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    freopen("grendizer.in", "r", stdin);
//    freopen ("myfile.txt","w",stdout);
    ll n;
    cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    ll c = 0;
    ll x = 0;
    for (int i = 0; i < n; i++) {
        c += v[i] / 2;
        if (v[i] % 2) {
            x++;
        } else{
            c += x / 2;
            x = 0;
        }
    }

    cout << c << endl;

    return 0;
}


#include<bits/stdc++.h>

typedef long long ll;
#define EPSILON 1e-6
using namespace std;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    freopen("grendizer.in", "r", stdin);
//    freopen ("myfile.txt","w",stdout);
    ll n;
    cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    ll c = 0;
    ll x = 0;
    int y = -1;
    v.push_back(0);
    for (int i = 0; i <= n; i++) {
        c += v[i] / 2;
        if (v[i] % 2) {
            x++;
        } else {
            c += x / 2;
            if (x % 2) {
                if (y == -1) {
                    y = i - 1;
                } else {
                    if ((i - y) % 2 == 0) {
                        c++;
                        y = i - 1;
                    }
                }
            }
            x = 0;
        }
    }
//    c += x / 2;
    cout << c << endl;

    return 0;
}


#include<bits/stdc++.h>

typedef long long ll;
#define EPSILON 1e-6
using namespace std;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    freopen("grendizer.in", "r", stdin);
//    freopen ("myfile.txt","w",stdout);
    ll n;
    cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    ll c = 0;
    ll x = 0;
    int y = -1;
    v.push_back(0);
    int even = 0, odd = 0;
    for (int i = 0; i <= n; i++) {
        c += v[i] / 2;
        if (v[i] % 2) {
            if (i % 2) {
                if (even) {
                    even--;
                    c++;
                } else {
                    odd++;
                }
            } else {
                if(odd){
                    odd--;
                    c++;
                } else{
                    even++;
                }
            }
        }
    }
    cout << c << endl;

    return 0;
}


#include<bits/stdc++.h>

typedef long long ll;
#define EPSILON 1e-6
using namespace std;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    freopen("grendizer.in", "r", stdin);
//    freopen ("myfile.txt","w",stdout);
    ll n;
    cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    ll c = 0;
    ll x = 0;
    int y = -1;
    v.push_back(0);
    for (int i = 0; i <= n; i++) {
        c += v[i] / 2;
        if (v[i] % 2) {
            x++;
        } else {
            c += x / 2;
            if (x % 2) {
                if (y == -1) {
                    y = i - 1;
                } else {
                    if ((i - y) % 2 == 0) {
                        c++;
                    }
                }
            }
            x = 0;
        }
    }
    c += x / 2;
    cout << c << endl;

    return 0;
}


#include<bits/stdc++.h>

typedef long long ll;
#define EPSILON 1e-6
using namespace std;
bool k[1000006];
bool kk[1000006];

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    freopen("grendizer.in", "r", stdin);
//    freopen ("myfile.txt","w",stdout);
    int n;
    cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    ll cc = 0;
    vector<ll> vv;
    int p = 0;
    for (int i = v.size() - 1; i >= 0; i--) {
        for (int j = 0; j < v[i] - p; j++) {
            vv.push_back(i + 1);
        }
        p = v[i];
    }
    ll c = 0;

    for (int i = 0; i < n; i++) {
        c += v[i] / 2;
        if (v[i] % 2 && i + 1 < n && !k[i]) {
            c++;
            k[i + 1] = 1;
            v[i + 1]--;
        }
    }

    for (int i = 0; i < vv.size(); i++) {
        cc += vv[i] / 2;
        if (vv[i] % 2 && i + 1 < vv.size() && !kk[i]) {
            cc++;
            kk[i + 1] = 1;
            vv[i + 1]--;
        }
    }
    cout << max(cc, c) << endl;

    return 0;
}


#include<bits/stdc++.h>

typedef long long ll;
#define EPSILON 1e-6
using namespace std;
int a[200005];

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    freopen("grendizer.in", "r", stdin);
//    freopen ("myfile.txt","w",stdout);
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int mn = n, z = n;
    for (int i = 0; i < k; i++) {
        char c = s[i];
        int x = -1, y = -1;
        for (int j = i; j < n; j += k) {
            if (s[j] < c) {
                s[j] = c;
                mn = min(mn, j);
            }
            if (s[j] > c && j < mn) {
                if (x == -1 && y == -1) {
                    x = j - k;
                    y = j - i - 1;
                }
            }
            s[j] = c;
        }
        if (x != -1 && y != -1) {
            for (int j = y; j >= x; j--) {
                if (s[j] != '9') {
                    z = min(z, j);
                    break;
                }
            }
        }
    }
    if (z < mn) {
        s[z%k]++;
        for (int i = z + 1; i < k; i++) {
            s[i] = '0';
        }
        for (int i = 0; i < k; i++) {
            char c = s[i];
            for (int j = i; j < n; j += k) {
                s[j] = c;
            }
        }

    }
    cout << n << "\n";
    cout << s << "\n";

    return 0;
}


#include<bits/stdc++.h>

typedef long long ll;
#define EPSILON 1e-6
using namespace std;

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    freopen("grendizer.in", "r", stdin);
//    freopen ("myfile.txt","w",stdout);
    ll n;
    cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    ll c = 0;
    ll x = 0;
    for (int i = 0; i < n; i++) {
        c += v[i] / 2;
        if (v[i] % 2) {
            x++;
        } else{
            c += x / 2;
            x = 0;
        }
    }
    c += x / 2;
    cout << c << endl;

    return 0;
}


#include<bits/stdc++.h>

typedef long long ll;
#define EPSILON 1e-6
using namespace std;
bool k[1000006];

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    freopen("grendizer.in", "r", stdin);
//    freopen ("myfile.txt","w",stdout);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    int c = 0;

    for (int i = 0; i < n; i++) {
        c += v[i] / 2;
        if (v[i] % 2 && i + 1 < n && !k[i]) {
            c++;
            k[i + 1] = 1;
            v[i + 1]--;
        }
    }
    cout<<c<<endl;

    return 0;
}


#include<bits/stdc++.h>

typedef long long ll;
#define EPSILON 1e-6
using namespace std;
bool k[1000006];

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
//    freopen("grendizer.in", "r", stdin);
//    freopen ("myfile.txt","w",stdout);
    ll n;
    cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    ll c = 0;

    for (int i = 0; i < n; i++) {
        c += v[i] / 2;
        if (v[i] % 2 && i + 1 < n && !k[i]) {
            c++;
            k[i + 1] = 1;
            v[i + 1]--;
        }
    }
    cout<<c<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 3e5+2;

int a[N], b[N];
//~ int a;
//~ int x, y, z;
int n, m, l;
//~ int b, c, d;

int main() {
    scanf("%d", &n);
    int j = 0, cnt = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", a+i);
        if (i > 0 && a[i] < a[i-1]) {
            b[j++] = cnt;
        }
        ++cnt;
    }
    b[j++] = n;
    sort(b, b+j, greater<int>());
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] > 1) {
            ans += a[i]/2;
            a[i] %= 2;
        }
        if (a[i] != 1 || i == 0 || a[i-1] != 1) continue;
        a[i] = a[i-1] = 0;
        ++ans;
    }
    long long ans2 = 0;
    for (int i = 0; i < j; ++i) {
        if (b[i]%2>1) {
            ans2 += b[i]/2;
            b[i] %= 2;
        }
        if (b[i] != 1 || i == 0 || b[i-1] != 1) continue;
        b[i] = b[i-1] = 0;
        ++ans2;
    }
    printf("%I64d", max(ans, ans2));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 3e5+2;

int a[N], b[N];
//~ int a;
//~ int x, y, z;
int n, m, l;
//~ int b, c, d;

int main() {
    scanf("%d", &n);
    int j = 0, cnt = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", a+i);
        if (i > 0 && a[i] < a[i-1]) {
            b[j++] = cnt;
        }
        ++cnt;
    }
    b[j++] = n;
    sort(b, b+j, greater<int>());
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] > 1) {
            ans += a[i]/2;
            a[i] %= 2;
        }
        if (a[i] != 1 || i == 0 || a[i-1] != 1) continue;
        a[i] = a[i-1] = 0;
        ++ans;
    }
    long long ans2 = 0;
    for (int i = 0; i < j; ++i) {
        if (b[i] > 1) {
            ans2 += b[i]/2;
            b[i] %= 2;
        }
        if (b[i] != 1 || i == 0 || b[i-1] != 1) continue;
        b[i] = b[i-1] = 0;
        ++ans2;
    }
    printf("%I64d", max(ans, ans2));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 3e5+2;

int a[N], b[N];
//~ int a;
//~ int x, y, z;
int n, m, l;
//~ int b, c, d;

int main() {
    scanf("%d", &n);
    int j = 0, cnt = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d", a+i);
        ++cnt;
        if (i > 0 && a[i] < a[i-1]) {
            b[j++] = cnt-1;
        }
    }
    b[j++] = n;
    sort(b, b+j, greater<int>());
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i]%2==0) {
            ans += a[i]/2;
            a[i] = 0;
        } else {
            if (a[i] > 1) {
                ans += a[i]/2;
                a[i] = 1;
            } else {
                if (i == 0) continue;
                if (a[i-1] != 1) continue;
                ans += 1;
                a[i] = a[i-1] = 0;
            }
        }
    }
    int ans2 = 0;
    for (int i = 0; i < j; ++i) {
        if (b[i]%2==0) {
            ans2 += b[i]/2;
            b[i] = 0;
        } else {
            if (b[i] > 1) {
                ans2 += b[i]/2;
                b[i] = 1;
            } else {
                if (i == 0) continue;
                if (b[i-1] != 1) continue;
                ans2 += 1;
                b[i] = b[i-1] = 0;
            }
        }
    }
    printf("%d", max(ans, ans2));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int n;

int main() {
    scanf("%d", &n);
    int ans[2] = {};
    for (int i = 0; i < n; ++i) {
        int x; scanf("%d", &x);
        ans[i%2] += x/2;
        ans[(i+1)%2] += (x+1)/2;
    }
    printf("%d", min(ans[0], ans[1]));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int n;

int main() {
    scanf("%d", &n);
    long long ans[2] = {};
    for (int i = 0; i < n; ++i) {
        int x; scanf("%d", &x);
        ans[i%2] += x/2;
        ans[(i+1)%2] += (x+1)/2;
    }
    printf("%I64d", min(ans[0], ans[1]));
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend()
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))
#define inf           (int)(2e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int>
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve() {
    int n;
    cin >> n;
    int a[n];
    int ans = 0;
    vi v;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        int j = i;
        int sum = 0;
        while(j < n && a[j]%2 == a[i]%2){
            sum += a[j];
            j++;
        }
        ans += sum/2;
        if(a[i]%2 == (j-i)%2){
            v.pb(a[i]%2);
        }
        i = j-1;
    }
    int one = 0, zero = 0;
    for(int i = 0; i < si(v); i++){
        if(v[i] && one && zero){
            ans++;
            one = 0, zero = 0;
        }
        else if(v[i])one = 1;
        else if(!v[i] && one)zero = 1;
    }
    cout << ans << endl;
}

signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1;
    start = clock();

    cout << fixed << setprecision(20);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif

    //cin >> t;

    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": ";
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend()
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))
#define inf           (int)(2e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int>
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

int odd(int x){
    return (x+1)/2;
}

int even(int x){
    return x/2;
}

void solve() {
    int n;
    cin >> n;
    int a[n+1];
    int ans1 = 0, ans2 = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(i%2){
            ans1 += even(a[i]);
            ans2 += odd(a[i]);
        } else {
            ans1 += odd(a[i]);
            ans2 += even(a[i]);
        }
    }
    cout << min(ans1, ans2) << endl;
}

signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1;
    start = clock();

    cout << fixed << setprecision(20);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif

    //cin >> t;

    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": ";
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend()
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))
#define inf           (int)(2e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int>
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve() {
    int n;
    cin >> n;
    int a[n];
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int eve = 0, odd = 0;
    for(int i = 0; i < n; i++){
        if (a[i]%2 == 0) {
            ans += a[i]/2;
            eve++;
        } else {
            if(eve%2 == 0 && odd){
                ans += (a[i]+1)/2;
                odd = 0;
            } else {
                ans += a[i]/2;
                odd = 1;
            } eve = 0;
        }
        //cout << ans << endl;
    }
    cout << ans << endl;
}

signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1;
    start = clock();

    cout << fixed << setprecision(20);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif

    //cin >> t;

    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": ";
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define int           long long
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend()
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))
#define inf           (int)(2e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int>
#define vpi           vector<pii >

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){
    cerr << name << " = " << arg1 << endl;
}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args){
    const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);
}
template<typename T1, typename T2> istream& operator>>(istream& in, pair<T1, T2> &q){
    in >> q.F >> q.S; return in;
}
template<typename T1, typename T2> ostream& operator<<(ostream& out, pair<T1, T2> &q){
    out << q.F << " " << q.S; return out;
}
template< typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F+p2.F, p1.S+p2.S};
}
template< typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){
    return {p1.F-p2.F, p1.S-p2.S};
}

void solve() {
    int n;
    cin >> n;
    int a[n+1];
    int ans = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        ans += a[i]/2;
    }
    for(int i = 0; i < n; i++){
        if(a[i]%2 == 0)continue;
        int j = i+1;
        while(j < n && a[j]%2 == 0){
            j++;
        }
        if(j < n && (j-i-1)%2 == 0)ans++;
        i = j;
    }
    cout << ans << endl;
}

signed main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int t = 1;
    start = clock();

    cout << fixed << setprecision(20);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif

    //cin >> t;

    for(int i = 1; i <= t; ++i){
        //cout << "Case #" << i << ": ";
        solve();
        //cout << endl;
    }
    //cerr << time(start);
    return 0;
}


//I read the news today, oh boy
//About a lucky man who made the grade

#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=1e6;

ll A[N];

int main(){
	fastio;
	ll n; cin>>n;
	ll acum=0;
	For(i,0,n){
		cin>>A[i];
		acum+=A[i];
	}
	For(i,0,n){
		if(A[i]&1){
			if(i<n-1 && A[i+1]&1) continue;
			acum--;
		}
	}
	cout<<acum/2<<endl;
	return 0;
}


//I read the news today, oh boy
//About a lucky man who made the grade

#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=1e6;

ll A[N];

int main(){
	fastio;
	ll n; cin>>n;
	ll w=0, b=0, x, y;
	For(i,0,n)
		cin>>A[i];
	For(i,0,n){
		x = A[i]/2;
		y = A[i]-x;
		if(i&1) swap(x,y);
		w+=x;
		b+=y;
	}
	cout << min(w,b) << endl;
	return 0;
}


//I read the news today, oh boy
//About a lucky man who made the grade

#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=1e6;

ll A[N];

int main(){
	fastio;
	ll n; cin>>n;
	ll acum=0;
	For(i,0,n){
		cin>>A[i];
		acum+=A[i];
	}
	ll left=0;
	ll contP=0;
	For(i,0,n){
		if(A[i]&1){
			if(!(contP&1) && left) left--;
			else left++;
			contP=0;
		}else contP++;
	}
	trace(left);
	acum-=left;
	cout<<acum/2<<endl;
	return 0;
}


//I read the news today, oh boy
//About a lucky man who made the grade

#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=1e6;

ll A[N];

int main(){
	fastio;
	ll n; cin>>n;
	ll acum=0;
	For(i,0,n){
		cin>>A[i];
		acum+=A[i];
	}
	int left=0;
	int contP=0;
	For(i,0,n){
		if(A[i]&1){
			if(i<n-1 && A[i+1]&1){
				i++;
				contP=0;
				continue;
			}
			if(!(contP&1) && left) left--;
			else left++;
			contP=0;
		}else contP++;
	}
	acum-=left;
	cout<<acum/2<<endl;
	return 0;
}


//I read the news today, oh boy
//About a lucky man who made the grade

#include <vector>
#include <iostream>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ll((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
#define roF(i,a,b) for(ll i = ll(a); i >= ll(b); i--)
using namespace std;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

const ll N=1e6;

ll A[N];

int main(){
	fastio;
	ll n; cin>>n;
	ll acum=0;
	For(i,0,n){
		cin>>A[i];
		acum+=A[i];
	}
	For(i,0,n){
		if(A[i]&1){
			if(i<n-1 && A[i+1]&1) continue;
			acum--;
			i++;
		}
	}
	cout<<acum/2<<endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#define ll long long
#define maxn 300005 /*rem*/
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns;
   if (b & 1) ns = ns * a;
   return ns;
}
int n;
int a[maxn];
ll s[2];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]),
		s[i % 2] += a[i] / 2,
		s[(i + 1) % 2] += (a[i] + 1) / 2;
	cout << min(s[0], s[1]) << endl;
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
#define ll long long
#define maxn 300005 /*rem*/
#define fi first
#define se second
using namespace std;
ll ksm(ll a, ll b) {
   if (!b) return 1;
   ll ns = ksm(a, b >> 1);
   ns = ns * ns % mod;
   if (b & 1) ns = ns * a % mod;
   return ns;
}
int n;
int a[maxn];
ll s[2];
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]),
		s[i % 2] += a[i] / 2,
		s[(i + 1) % 2] += (a[i] + 1) / 2;
	cout << min(s[0], s[1]) << endl;
	return 0;
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

const int MAXN = 300030;
const int INF = 0x3f3f3f3f;
ll a[MAXN];
ll n, cnt, cur, ans;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
		ans += a[i] / 2;
		if (a[i] % 2 == 1 && cur == 0)
			cur = i;
	}
	for (int i = cur + 1; i <= n; ++ i)
		if (a[i] % 2 == 1)
		{
			if ((i - cur) % 2 == 1)
				++ ans, cur = INF;
			else
				cur = i;
		}
	cout << ans;
	return 0;
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

const int MAXN = 300030;
const int INF = 0x3f3f3f3f;
ll a[MAXN], pos[MAXN];
bool flag[MAXN];
ll n, cnt;
ll ans;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
		if (a[i] % 2 == 1)
			pos[++ cnt] = i;
		else
			ans += a[i] / 2;
	}
	for (int i = 2; i <= cnt; ++ i)
		if ((pos[i] - pos[i - 1]) % 2 == 1)
		{
			ans += (a[pos[i]] + a[pos[i - 1]]) / 2;
			flag[i] = 1, flag[i - 1] = 1;
			++ i;
		}
	for (int i = 1; i <= cnt; ++ i)
		if (!flag[i])
			ans += a[pos[i]] / 2;
	cout << ans;
	return 0;
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

const int MAXN = 300030;
const int INF = 0x3f3f3f3f;
ll a[MAXN], pos[MAXN];
bool flag[MAXN];
ll n, cnt;
ll ans;

int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++ i)
	{
		cin >> a[i];
		if (a[i] % 2 == 1)
			pos[++ cnt] = i;
		else
			ans += a[i] / 2;
	}
	for (int i = 2; i <= cnt; ++ i)
		if ((pos[i] - pos[i - 1]) % 2 == 1 && !flag[i - 1])
		{
			ans += (a[pos[i]] + a[pos[i - 1]]) / 2;
			flag[i] = 1, flag[i - 1] = 1;
		}
	for (int i = 1; i <= cnt; ++ i)
		if (!flag[i])
			ans += a[pos[i]] / 2;
	cout << ans;
	return 0;
}


#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

const int MAXN = 300030;
const int INF = 0x3f3f3f3f;
int a[MAXN], pos[MAXN];
bool flag[MAXN];
int n, cnt;
ll ans;

int main()
{
	scanf ("%d", &n);
	for (int i = 1; i <= n; ++ i)
	{
		scanf ("%d", &a[i]);
		if (a[i] & 1)
			pos[++ cnt] = i;
		else
			ans += (ll)a[i] / 2;
	}
	for (int i = 2; i <= cnt; ++ i)
		if ((pos[i] - pos[i - 1]) % 2 == 1)
		{
			ans += (ll)(a[pos[i]] + a[pos[i - 1]]) / 2;
			flag[i] = 1, flag[i - 1] = 1;
			++ i;
		}
	for (int i = 1; i <= cnt; ++ i)
		if (!flag[i])
			ans += (ll)a[pos[i]] / 2;
	cout << ans;
	return 0;
}


#include<bits/stdc++.h>
/*#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>*/
using namespace std;
typedef long long ll;
#define rep(i,s,e) for(register int i=s;i<=e;i++)
#define repp(i,s,e) for(register int i=s;i<e;i++)
#define dep(i,e,s) for(register int i=e;i>=s;i--)
#define pb push_back
#define pf(a) printf("%d",a)
#define sf(a) scanf("%d",&a)
#define pii pair<int,int>
#define RI register int
#define mst(a,x) memset(a,x,sizeof(a))
#define db double
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int inf=0x3f3f3f3f;
const int N=3e5+10;
const ll mod=1e9+7;
int n,m,k;
int a[N];
void work(){
    cin>>n;
	rep(i,1,n){
		sf(a[i]);
	}
	ll s=0;
	dep(i,n-1,1){
		if (a[i+1]<a[i]-1){
		    s+=(a[i]-a[i+1])/2;
			a[i]-=(a[i]-a[i+1])/2*2;
		}
    }
	int h=0;
    if (a[n]==1){
    	h=0;
	}
	else{
		h=1;
	}
	ll r=0;
	a[n+1]=a[n];
	dep(i,n,1){
		if(a[i]!=a[i+1]&&h==1){
			r+=a[i+1];
		}
		else{
			r+=a[i];
		}
		if (a[i]==1){
			h=0;
		}
		else
		    h=1-h;
	}
	//6 10 5 3 1 1 1
	s+=r/2;
	cout<<s<<endl;
}
int main(){
	int t;
	t=1;
	while(t--){
		work();
	}
	return 0;
}


#include<bits/stdc++.h>
/*#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>*/
using namespace std;
typedef long long ll;
#define rep(i,s,e) for(register int i=s;i<=e;i++)
#define repp(i,s,e) for(register int i=s;i<e;i++)
#define dep(i,e,s) for(register int i=e;i>=s;i--)
#define pb push_back
#define pf(a) printf("%d",a)
#define sf(a) scanf("%d",&a)
#define pii pair<int,int>
#define RI register int
#define mst(a,x) memset(a,x,sizeof(a))
#define db double
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int inf=0x3f3f3f3f;
const int N=3e5+10;
const ll mod=1e9+7;
int n,m,k;
int a[N];
void work(){
    cin>>n;
	rep(i,1,n){
		sf(a[i]);
	}
	ll s=0;
	dep(i,n-1,1){
		if (a[i+1]<a[i]-1){
		    s+=(a[i]-a[i+1])/2;
			a[i]-=(a[i]-a[i+1])/2*2;
		}
    }
	int h=0;
	ll r=0;
	a[n+1]=a[n];
	dep(i,n,1){
		if(a[i]!=a[i+1]&&h==0){
			r+=a[i+1];
		}
		else{
			r+=a[i];
		}
		h=1-h;
	}
	s+=r/2;
	cout<<s<<endl;
}
int main(){
	int t;
	t=1;
	while(t--){
		work();
	}
	return 0;
}


#include<bits/stdc++.h>
/*#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>*/
using namespace std;
typedef long long ll;
#define rep(i,s,e) for(register int i=s;i<=e;i++)
#define repp(i,s,e) for(register int i=s;i<e;i++)
#define dep(i,e,s) for(register int i=e;i>=s;i--)
#define pb push_back
#define pf(a) printf("%d",a)
#define sf(a) scanf("%d",&a)
#define pii pair<int,int>
#define RI register int
#define mst(a,x) memset(a,x,sizeof(a))
#define db double
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int inf=0x3f3f3f3f;
const int N=3e5+10;
const ll mod=1e9+7;
int n,m,k;
int a[N];
void work(){
    cin>>n;
	rep(i,1,n){
		sf(a[i]);
	}
	ll s=0;
	dep(i,n-1,1){
		if (a[i+1]<a[i]-1){
			a[i]-=(a[i]-a[i+1])/2*2;
			s+=(a[i]-a[i+1])/2;
		}
	}
	int h=0;
	ll r=0;
	a[n+1]=a[n];
	dep(i,n,1){
		if(a[i]!=a[i+1]&&h==0){
			r+=a[i+1];
		}
		else{
			r+=a[i];
		}
		h=1-h;
	}
	s+=r/2;
	cout<<s<<endl;
}
int main(){
	int t;
	t=1;
	while(t--){
		work();
	}
	return 0;
}


#include<bits/stdc++.h>
/*#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>*/
using namespace std;
typedef long long ll;
#define rep(i,s,e) for(register int i=s;i<=e;i++)
#define repp(i,s,e) for(register int i=s;i<e;i++)
#define dep(i,e,s) for(register int i=e;i>=s;i--)
#define pb push_back
#define pf(a) printf("%d",a)
#define sf(a) scanf("%d",&a)
#define pii pair<int,int>
#define RI register int
#define mst(a,x) memset(a,x,sizeof(a))
#define db double
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int inf=0x3f3f3f3f;
const int N=2e3+10;
const ll mod=1e9+7;
int n,m,k;
int a[N];
void work(){
    cin>>n;
	rep(i,1,n){
		sf(a[i]);
	}
	ll s=0;
	dep(i,n-1,1){
		if (a[i+1]<a[i]-1){
			a[i]-=(a[i]-a[i+1])/2*2;
			s+=(a[i]-a[i+1])/2;
		}
	}
	int h=0;
	ll r=0;
	a[n+1]=a[n];
	dep(i,n,1){
		if(a[i]!=a[i+1]&&h==0){
			r+=a[i+1];
		}
		else{
			r+=a[i];
		}
		h=1-h;
	}
	s+=r/2;
	cout<<s<<endl;
}
int main(){
	int t;
	t=1;
	while(t--){
		work();
	}
	return 0;
}


#include<bits/stdc++.h>
/*#include <iostream>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <algorithm>*/
using namespace std;
typedef long long ll;
#define rep(i,s,e) for(register int i=s;i<=e;i++)
#define repp(i,s,e) for(register int i=s;i<e;i++)
#define dep(i,e,s) for(register int i=e;i>=s;i--)
#define pb push_back
#define pf(a) printf("%d",a)
#define sf(a) scanf("%d",&a)
#define pii pair<int,int>
#define RI register int
#define mst(a,x) memset(a,x,sizeof(a))
#define db double
#define lson l , m , rt << 1
#define rson m + 1 , r , rt << 1 | 1
const int inf=0x3f3f3f3f;
const int N=3e5+10;
const ll mod=1e9+7;
int n,m,k;
int a[N];
void work(){
    cin>>n;
	rep(i,1,n){
		sf(a[i]);
	}
	ll s=0;
	int h=0;
	ll s1=0,s2=0;
	rep(i,1,n){
		s+=a[i];
		if (h==0){
			s1+=a[i]-a[i]/2;
			s2+=a[i]/2;
		}
		else{
			s2+=a[i]-a[i]/2;
			s1+=a[i]/2;
		}
		h=1-h;
	}
	s=min(s1,s2);
	cout<<s<<endl;
}
int main(){
	int t;
	t=1;
	while(t--){
		work();
	}
	return 0;
}


#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define lowbit(x) (x&(-x))
#define int long long
int a[300000],b[300000];
int c[300000];
int n;
signed main(){

    cin>>n;
    rep(i,1,n)cin>>a[i];
    int cnt = 0;
    rep(i,1,n){
        cnt += a[i]/2;
        b[i]=a[i]%2;
    }

    rep(i,1,n){
        if(b[i]){
            if(i==n)break;
            int p=i+1;
            while(p<=n && !b[i])p++;
            if(p>n)break;
            int len=p-i+1;
            if(len&1){
                cnt ++ ;
            }
            i=p+1;
        }
    }
        rep(i,1,n){
        if(b[i]){
            if(i==n)break;
            int p=i+1;
            while(p<=n && !b[i])p++;
            if(p>n)break;
            int len=p-i+1;
            if(len&1){
                cnt ++ ;
            }
            i=p+1;
        }
    }
    cout<<cnt<<endl;

  //getchar();  getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define lowbit(x) (x&(-x))
#define int long long
int a[300000],b[300000];
int c[300000];
int n;
int mp[20];
signed main(){

    cin>>n;
    rep(i,1,n)cin>>a[i];
    int cnt = 0;
    rep(i,1,n){
        cnt += a[i]/2;
        b[i]=a[i]%2;
    }
   // cout<<cnt<<endl;
    rep(i,1,n){
        if(b[i]){
            int t=i%2;
            if(mp[t^1])
            {
                mp[t^1]--;
                cnt ++;
            }
            else mp[t]++;
        }
    }
    cout<<cnt<<endl;

   //getchar();  getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define lowbit(x) (x&(-x))
#define int long long
int a[300000],b[300000];
int c[300000];
int n;
signed main(){

    cin>>n;
    rep(i,1,n)cin>>a[i];
    int cnt = 0;
    rep(i,1,n){
        cnt += a[i]/2;
        b[i]=a[i]%2;
    }

    rep(i,1,n){
        if(b[i]){
            if(i==n)break;
            int p=i+1;
            while(p<=n && !b[i])p++;
            if(p>n)break;
            int len=p-i+1;
            if(len&1){
                cnt ++ ;
            }
            i=p+1;
        }
    }
    cout<<cnt<<endl;

  //getchar();  getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define lowbit(x) (x&(-x))
#define int long long
int a[300000],b[300000];
int c[300000];
int n;
signed main(){

    cin>>n;
    rep(i,1,n)cin>>a[i];
    int cnt = 0;
    rep(i,1,n){
        cnt += a[i]/2;
        b[i]=a[i]%2;
    }

    rep(i,1,n){
        if(b[i]){
            if(i==n)break;
            int p=i+1;
            while(p<=n && !b[i])p++;
            if(p>n)break;
            int len=p-i+1;
            if(len&1){
                cnt ++ ;
            }
            i=p;
        }
    }
    cout<<cnt<<endl;

  // getchar();  getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define lowbit(x) (x&(-x))
#define int long long
int a[300000],b[300000];
int c[300000];
int n;
signed main(){

    cin>>n;
    rep(i,1,n)cin>>a[i];
    int cnt = 0;
    rep(i,1,n){
        cnt += a[i]/2;
        b[i]=a[i]%2;
    }
    rep(i,1,n-1){
        if(b[i]&&b[i+1]){
            cnt ++ ;
            b[i]=b[i+1]=0;
        }
    }
    rep(i,1,n){
        if(b[i]){
            if(i==n)break;
            int p=i+1;
            while(p<=n && !b[i])p++;
            if(p>n)break;
            int len=p-i+1;
            if(len&1){
                cnt ++ ;
            }
            i=p+1;
        }
    }
    cout<<cnt<<endl;

  // getchar();  getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define lowbit(x) (x&(-x))
#define int long long
int a[300000],b[300000];
int c[300000];
int n;
signed main(){

    cin>>n;
    rep(i,1,n)cin>>a[i];
    int cnt = 0;
    rep(i,1,n){
        cnt += a[i]/2;
        b[i]=a[i]%2;
    }

    rep(i,1,n){
        if(b[i]){
            if(i==n)break;
            int p=i+1;
            while(p<=n && !b[p])p++;
            if(p>n)break;
            int len=p-i+1;
            if(len&1){
                cnt ++ ;
            }
            i=p;
        }
    }
    cout<<cnt<<endl;

  // getchar();  getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define lowbit(x) (x&(-x))
#define int long long
int a[300000],b[300000];
int c[300000];
int n;
signed main(){

    cin>>n;
    rep(i,1,n)cin>>a[i];
    int cnt = 0;
    rep(i,1,n){
        cnt += a[i]/2;
        b[i]=a[i]%2;
    }

    rep(i,1,n){
        if(b[i]){
            if(i==n)break;
            int p=i+1;
            while(p<=n && !b[i])p++;
            if(p>n)break;
            int len=p-i+1;
            if(len&1){
                cnt ++ ;
            }
            i=p;
        }
    }
        rep(i,1,n){
        if(b[i]){
            if(i==n)break;
            int p=i+1;
            while(p<=n && !b[i])p++;
            if(p>n)break;
            int len=p-i+1;
            if(len&1){
                cnt ++ ;
            }
            i=p;
        }
    }
    cout<<cnt<<endl;

  // getchar();  getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define lowbit(x) (x&(-x))
#define int long long
int a[300000],b[300000];
int c[300000];
int n;
signed main(){

    cin>>n;
    rep(i,1,n)cin>>a[i];
    int cnt = 0;
    rep(i,1,n){
        cnt += a[i]/2;
        b[i]=a[i]%2;
    }
   // cout<<cnt<<endl;
    rep(i,1,n){
        if(b[i]){
            if(i==n)break;
            int p=i+1;
            while(p<=n && !b[p])p++;
            if(p>n)break;
            int len=p-i;
            if(len&1){
                cnt ++ ;
            }
         //   cout<<i<<" "<<p<<endl;
            i=p;
        }
    }
    cout<<cnt<<endl;

   //getchar();  getchar();
}


#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define all(v) (v).begin(),(v).end()
#define lowbit(x) (x&(-x))
#define int long long
int a[300000],b[300000];
int c[300000];
int n;
signed main(){

    cin>>n;
    rep(i,1,n)cin>>a[i];
    int cnt = 0;
    rep(i,1,n){
        cnt += a[i]/2;
        b[i]=a[i]%2;
    }
    rep(i,1,n-1){
        if(b[i]&&b[i+1]){
            cnt ++ ;
            b[i]=b[i+1]=0;
        }
    }
    rep(i,1,n){
        if(b[i]){
            if(i==n)break;
            int p=i+1;
            while(p<=n && !b[i])p++;
            if(p>n)break;
            int len=p-i+1;
            if(len&1){
                cnt ++ ;
            }
            i=p;
        }
    }
    cout<<cnt<<endl;

  // getchar();  getchar();
}


#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
long long cnt[2] = {};
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, x;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        cnt[i & 1] += (x >> 1);
        cnt[(i & 1) ^ 1] += (x + 1) >> 1;
    }
    cout << min(cnt[0], cnt[1]) << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int cnt[2] = {};
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, x;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> x;
        cnt[i & 1] += (x >> 1);
        cnt[(i & 1) ^ 1] += (x + 1) >> 1;
    }
    cout << min(cnt[0], cnt[1]) << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 0, x; i < n; i++) {
        cin >> x;
        ans += x >> 1;
    }
    cout << ans << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int arr[N] = {};
int main() {
    int n;
    cin >> n;
    long long ans = 0;
    int r = 0;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        if (r) {
            ans += (arr[i] + r) >> 1;
            r = 0;
        }
        else {
            ans += arr[i] >> 1;
            if (arr[i] & 1) r = 1;
        }
    }
    cout << ans << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int arr[N] = {};
int main() {
    int n;
    cin >> n;
    long long ans = 0;
    int type = 0, r = 0;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        if (r) {
            if (type == 1 && arr[i] > 1) {
                ans += (arr[i] + 1) >> 1;
                if ((arr[i] + 1) & 1) {
                    type = 0, r = 1;
                }
                else r = 0;
            }
            else if (type == 0) {
                ans += (arr[i] + 1) >> 1;
                if ((arr[i] + 1) & 1) {
                    type = 1, r = 1;
                }
                else r = 0;
            }
            else {
                r = 1, type = 0;
            }
        }
        else {
            ans += arr[i] >> 1;
            if (arr[i] & 1) {
                type = 0, r = 1;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN=300010;
int N,M,A[MAXN];
int main()
{
	cin>>N;
	long long Ans=0;
	for (int i=1;i<=N;++i) scanf("%d",&A[i]),Ans+=A[i];
	int f=0;
	for (int i=1;i<=N;++i)
		if (f==0)
		{
			if (A[i]&1) f=1;
		}
		else if (f==1)
		{
			if (A[i]&1) f=0;
			else f=2;
		}
		else
		{
			if (A[i]%2==0) f=1;
			else if (A[i]==1) --Ans,f=1;
			else if (i<N && A[i+1]%2==1)
			{
				++i;
			}
			else --Ans,f=1;
		}
	if (f) --Ans;
	cout<<Ans/2<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN=300010;
int N,M,A[MAXN];
int main()
{
	cin>>N;
	long long Ans=0;
	for (int i=1;i<=N;++i) scanf("%d",&A[i]),Ans+=A[i]/2;
	int n=0,Cnt=0;
	for (int i=1;i<=N;++i) if (A[i]&1) ++n,Cnt+=(i%2);
	Ans+=min(Cnt,n-Cnt);
	cout<<Ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN=300010;
int N,M,A[MAXN];
int main()
{
	cin>>N;
	long long Ans=0;
	for (int i=1;i<=N;++i) scanf("%d",&A[i]),Ans+=A[i];
	int f=0;
	for (int i=1;i<=N;++i)
		if (f==0)
		{
			if (A[i]&1) f=1;
		}
		else if (f==1)
		{
			if (A[i]&1) f=0;
			else f=2;
		}
		else
		{
			if (A[i]&1) --Ans,f=1;
		}
	if (f) --Ans;
	cout<<Ans/2<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int MAXN=300010;
int N,A[MAXN];
int main()
{
	cin>>N;
	for (int i=1;i<=N;++i) scanf("%d",&A[i]);
	long long Ans=0;
	for (int i=1;i<=N;++i)
	{
		if (A[i]%2==0) Ans+=A[i]/2,A[i]=0;
		else
		{
			Ans+=A[i]/2,A[i]=1;
			if (i>1 && A[i-1]==1) ++Ans,A[i]=0;
		}
	}
	cout<<Ans<<endl;
	return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
   int n;
   cin >> n;
   vector<int> col;
   while(n--){
      int c;
      cin >> c;
      col.push_back(c);
   }

   int w, b = 0;
   bool curr = true;
   int total = 0;
   for(int i = col.size()-1; i>=0; i--){
      if(curr){
         w += (int)(ceil(col[i]/2.0));
         b += (int)(col[i]/2.0);
      }
      else{
         b += (int)(ceil(col[i]/2.0));
         w += (int)(col[i]/2.0);
      }
      curr = !curr;
   }
   cout << min(w, b) << endl;
   return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
   int n;
   cin >> n;
   vector<int> col;
   while(n--){
      int c;
      cin >> c;
      col.push_back(c);
   }

   int w, b = 0;
   bool curr = true;
   int total = 0;
   for(int i = col.size()-1; i>=0; i--){
      if(curr){
         w += ceil(col[i]/2);
         b += col[i]/2;
      }
      else{
         b += ceil(col[i]/2);
         w += col[i]/2;
      }
      curr = !curr;
   }
   cout << min(w, b) << endl;
   return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
   int n;
   cin >> n;
   vector<int> col;
   while(n--){
      int c;
      cin >> c;
      col.push_back(c);
   }

   long long w = 0, b = 0;
   bool curr = true;
   int total = 0;
   for(int i = col.size()-1; i>=0; i--){
      if(curr){
         w += (long long)(ceil(col[i]/2.0));
         b += (long long)(col[i]/2.0);
      }
      else{
         b += (long long)(ceil(col[i]/2.0));
         w += (long long)(col[i]/2.0);
      }
      curr = !curr;
   }
   cout << min(w, b) << endl;
   return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
   int n;
   cin >> n;
   vector<int> col;
   while(n--){
      int c;
      cin >> c;
      col.push_back(c);
   }

   long long w, b = 0;
   bool curr = true;
   int total = 0;
   for(int i = col.size()-1; i>=0; i--){
      if(curr){
         w += (long long)(ceil(col[i]/2.0));
         b += (long long)(col[i]/2.0);
      }
      else{
         b += (long long)(ceil(col[i]/2.0));
         w += (long long)(col[i]/2.0);
      }
      curr = !curr;
   }
   cout << min(w, b) << endl;
   return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#define N 300005
using namespace std;
typedef long long ll;
int n;
ll a[N];
int main() {
	cin>>n;
	int w = 0, b = 0;
	for (int i = 0; i < n; ++i) {
		cin>>a[i];
		if (i%2==0) {
			b += (a[i]+1)/2;
			w += a[i]/2;
		} else {
			w += (a[i]+1)/2;
			b += a[i]/2;
		}
	}
	cout<<min(b, w)<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#define N 300005
using namespace std;
typedef long long ll;
int n;
int a[N];
int main() {
	cin>>n;
	//int w = 0, b = 0;
	for (int i = 0; i < n; ++i) {
		cin>>a[i];
		// b += (a[i]+1)/2;
		// w += a[i]/2;
	}
	int tot=0;
	int i =0;
	while(i < n) {
		if (a[i] % 2 == 0) {
			tot += a[i]/2;
			i++;
		} else {
			if (i+1<n && a[i+1]%2) {
				tot += a[i]/2+a[i+1]/2;
				tot++;
				i+=2;
			} else {
				tot += a[i]/2;
				i++;
			}
		}
	}
	cout<<tot<<endl;
	//cout<<min(b, w)<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#define N 300005
using namespace std;
typedef long long ll;
int n;
int a[N];
int main() {
	cin>>n;
	int w = 0, b = 0;
	for (int i = 0; i < n; ++i) {
		cin>>a[i];
		b += (a[i]+1)/2;
		w += a[i]/2;
	}
	cout<<min(b, w)<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#define N 300005
using namespace std;
typedef long long ll;
int n;
ll a[N];
int main() {
	cin>>n;
	//int w = 0, b = 0;
	for (int i = 0; i < n; ++i) {
		cin>>a[i];
		// b += (a[i]+1)/2;
		// w += a[i]/2;
	}
	ll tot=0;
	int i =0;
	while(i < n) {
		if (a[i] % 2 == 0) {
			tot += a[i]/2;
			i++;
		} else {
			if (i+1<n && a[i+1]%2) {
				tot += a[i]/2+a[i+1]/2;
				tot++;
				i+=2;
			} else {
				tot += a[i]/2;
				i++;
			}
		}
	}
	cout<<tot<<endl;
	//cout<<min(b, w)<<endl;
	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#define N 300005
using namespace std;
typedef long long ll;
int n;
ll a[N];
int main() {
	cin>>n;
	ll w = 0, b = 0;
	for (int i = 0; i < n; ++i) {
		cin>>a[i];
		if (i%2==0) {
			b += (a[i]+1)/2;
			w += a[i]/2;
		} else {
			w += (a[i]+1)/2;
			b += a[i]/2;
		}
	}
	cout<<min(b, w)<<endl;
	return 0;
}


#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
using namespace std;
typedef long long ll;

int fa[500005], a[300005], b[2005];
int fi(int a)
{
	if (a == fa[a])
		return a;
	else return fa[a] = fi(fa[a]);
}
typedef pair<int, int> pa;
map<int, int> ma;
int che(int a)
{
	for (int i = 2; i*i <= a; i++)
		if (a%i == 0)
			return 1;
	return 0;
}
set<pa> se, se1;
int main()
{
	int t, c;
	string ss, s; int n, m;
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (cin >> n )
	{
		ll ans = 0, b=0, c=0;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}

		for (int i = 0; i < n; i++)
		{

			if (i%2)
			{
				b += (a[i] + 1) / 2;
				c += a[i] / 2;
		}
			else{
				b += a[i] / 2;
				c += (a[i] + 1) / 2;
			}

		}
		cout << min(b,c) << endl;

	}
	return 0;
}


#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
using namespace std;
typedef long long ll;

int fa[500005], a[300005], b[2005];
int fi(int a)
{
	if (a == fa[a])
		return a;
	else return fa[a] = fi(fa[a]);
}
typedef pair<int, int> pa;
map<int, int> ma;
int che(int a)
{
	for (int i = 2; i*i <= a; i++)
		if (a%i == 0)
			return 1;
	return 0;
}
set<pa> se, se1;
int main()
{
	int t, c;
	string ss, s; int n, m;
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (cin >> n )
	{
		int ans = 0, no = 0, lr;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		int ti = 0, sg;
		for (int i = 0; i < n; i++)
		{
			sg = 1;
			ans += a[i] / 2;
			if (a[i] % 2)
			{
				if(ti)
					if (lr % 2 && i % 2 == 0 || lr % 2 == 0 && i % 2)
					{
						ans++;
						sg = 0;
					}
				if(sg)
				lr = i;
			}
			ti++;
		}
		cout << ans  << endl;

	}
	return 0;
}


#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
using namespace std;
typedef long long ll;

int fa[500005], a[300005], b[2005];
int fi(int a)
{
	if (a == fa[a])
		return a;
	else return fa[a] = fi(fa[a]);
}
typedef pair<int, int> pa;
map<int, int> ma;
int che(int a)
{
	for (int i = 2; i*i <= a; i++)
		if (a%i == 0)
			return 1;
	return 0;
}
set<pa> se, se1;
int main()
{
	int t, c;
	string ss, s; int n, m;
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (cin >> n )
	{
		ll ans = 0, lr;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		int ti = 0, sg;
		for (int i = 0; i < n; i++)
		{
			sg = 1;
			ans += a[i] / 2;
			if (a[i] % 2)
			{
				if(ti)
					if (lr % 2 && i % 2 == 0 || lr % 2 == 0 && i % 2)
					{
						ans++;
						sg = 0;
					}
				if(sg)
				lr = i;
			}
			ti++;
		}
		cout << ans  << endl;

	}
	return 0;
}


#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
using namespace std;
typedef long long ll;

int fa[500005], a[300005], b[2005];
int fi(int a)
{
	if (a == fa[a])
		return a;
	else return fa[a] = fi(fa[a]);
}
typedef pair<int, int> pa;
map<int, int> ma;
int che(int a)
{
	for (int i = 2; i*i <= a; i++)
		if (a%i == 0)
			return 1;
	return 0;
}
set<pa> se, se1;
int main()
{
	int t, c;
	string ss, s; int n, m;
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (cin >> n )
	{
		ll ans = 0, lr;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		int ti = 0, sg;
		for (int i = 0; i < n; i++)
		{
			sg = 1;
			ans += a[i] / 2;
			if (a[i] % 2)
			{
				if(ti)
					if (lr % 2 && i % 2 == 0 || lr % 2 == 0 && i % 2)
					{
						ans++;
						continue;
					}
				lr = i;
			}
			ti++;
		}
		cout << ans  << endl;

	}
	return 0;
}


#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
using namespace std;
typedef long long ll;

int fa[500005], a[300005], b[2005];
int fi(int a)
{
	if (a == fa[a])
		return a;
	else return fa[a] = fi(fa[a]);
}
typedef pair<int, int> pa;
map<int, int> ma;
int che(int a)
{
	for (int i = 2; i*i <= a; i++)
		if (a%i == 0)
			return 1;
	return 0;
}
set<pa> se, se1;
int main()
{
	int t, c;
	string ss, s; int n, m;
	ios::sync_with_stdio(false);
	cin.tie(0);
	while (cin >> n )
	{
		int ans = 0, no = 0, lr;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
		}
		int ti = 0;
		for (int i = 0; i < n; i++)
		{
			ans += a[i] / 2;
			if (a[i] % 2)
			{
				if(ti)
				if (lr % 2 && i % 2==0||lr%2==0&&i%2)
					ans++;
				lr = i;
			}
			ti++;
		}
		cout << ans  << endl;

	}
	return 0;
}


#include <bits/stdc++.h>
#define REP(i,n) for (long long i = 0;i < n;i++)
using namespace std;
typedef long long ll;
int dat[400000];
int main() {
#ifdef _DEBUG
	auto _debug_fp = freopen("in.txt", "r", stdin);
	if (!_debug_fp) return 1;
#endif
	/***********main************/
	int t, ans = 0;
	int j = 0, o = 0, n = 0;
	scanf("%d", &t);
	REP(i, t) {
		int temp;
		scanf("%d", &temp);
		if (temp & 1)
			dat[n++] = i;
		ans += temp / 2;
	}
	REP(i, n) {
		if (dat[i + 1]) {
			if ((dat[i + 1] - dat[i]) & 1) {
				ans++;
				i++;
			}
		}
	}
	printf("%d", ans);

	/****************************/
#ifdef _DEBUG
	fclose(_debug_fp);
	cout << "\n!=========END==========!\n";
#endif
	return 0;
}


#include <bits/stdc++.h>
#define REP(i,n) for (long long i = 0;i < n;i++)
using namespace std;
typedef long long ll;
int dat[400000];
int main() {
#ifdef _DEBUG
	auto _debug_fp = freopen("in.txt", "r", stdin);
	if (!_debug_fp) return 1;
#endif
	/***********main************/
	ll ans = 0;
	int t, j = 0, o = 0, n = 0;
	scanf("%d", &t);
	REP(i, t) {
		int temp;
		scanf("%d", &temp);
		if (temp & 1)
			dat[n++] = i + 1;
		ans += temp / 2;
	}
	REP(i, n) {
		if (dat[i + 1]) {
			int j = i;
			while (j >= 0) {
				if (dat[j] == 0)
					j--;
				else
					break;
			}
			if (j >= 0) {
				if ((dat[i + 1] - dat[j]) & 1) {
					ans++;
					dat[i + 1] = dat[j] = 0;
				}
			}
		}
	}
	printf("%lld", ans);

	/****************************/
#ifdef _DEBUG
	fclose(_debug_fp);
	cout << "\n!=========END==========!\n";
#endif
	return 0;
}


/* DELAPAN.3gp */
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
using namespace std;

#ifdef DEBUG
	#define debug(...) printf(__VA_ARGS__)
	#define GetTime() fprintf(stderr,"Running time: %.3lf second\n",((double)clock())/CLOCKS_PER_SEC)
#else
	#define debug(...)
	#define GetTime()
#endif

//type definitions
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vlnt;

//abbrevlations
#define A first
#define B second
#define MP make_pair
#define PB push_back

//macros
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n)-1; 0 <= i; --i)
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for (int i = (a); (b) <= i; --i)
#define FORIT(it,c) for (__typeof ((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define RESET(a,x) memset(a,x,sizeof(a))
#define EXIST(a,s) ((s).find(a) != (s).end())
#define MX(a,b) a = max((a),(b));
#define MN(a,b) a = min((a),(b));

inline void OPEN(const string &s) {
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

/* -------------- end of DELAPAN.3gp's template -------------- */

/** MATRIX TEMPLATE **/
typedef vector<long long> vl;
typedef vector<vl> vvl;
#define MOD 1000000007LL

vvl matrixUnit(int n) {
    vvl res(n, vl(n));
    for (int i = 0; i < n; i++)
        res[i][i] = 1;
    return res;
}
vvl matrixAdd(const vvl &a, const vvl &b) {
    int n = a.size();
    int m = a[0].size();
    vvl res(n, vl(m));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++)
            res[i][j] = (a[i][j] + b[i][j]) % MOD;
    return res;
}
vvl matrixMul(const vvl &a, const vvl &b) {
    int n = a.size();
    int m = a[0].size();
    int k = b[0].size();
    vvl res(n, vl(k));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < k; j++)
            for (int p = 0; p < m; p++)
                res[i][j] = (res[i][j] + a[i][p] * b[p][j]) % MOD;
    return res;
}
vvl matrixPow(const vvl &a, long long p) {
    if (p == 0)
        return matrixUnit(a.size());
    if (p & 1)
        return matrixMul(a, matrixPow(a, p - 1));
    return matrixPow(matrixMul(a, a), p / 2);
}
vvl matrixPowSum(const vvl &a, long long p) {
    int n = a.size();
    if (p == 0)
        return vvl(n, vl(n));
    if (p % 2 == 0)
        return matrixMul(matrixPowSum(a, p / 2), matrixAdd(matrixUnit(n), matrixPow(a, p / 2)));
    return matrixAdd(a, matrixMul(matrixPowSum(a, p - 1), a));
}

void print(const vvl &a) {
	REP(i, a.size()) {
		REP(j, a[i].size()) {
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

int n;
ll k, a[111];

int main() {
	cin >> n >> k;
	REP(i, n) {
		cin >> a[i];
	}

	vvl m(n, vl(n));
	REP(i, n) REP(j, n) {
		m[i][j] = __builtin_popcountll(a[i] ^ a[j]) % 3 == 0;
	}

	m = matrixPow(m, k - 1);
	ll ans = 0;
	REP(i, n) REP(j, n) {
		ans += m[i][j];
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}