#include <bits/stdc++.h>
#pragma GCC optimize("-O2")
using namespace std;
long long int tmod(long long int x, long long int m) { return (x % m + m) % m; }
class UnionFind {
 public:
  vector<int> p, rank;
  UnionFind(int N) {
    rank.assign(N, 1);
    p.assign(N, 0);
    for (int i = 0; i < N; i++) p[i] = i;
  }
  int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) {
    if (!isSameSet(i, j)) {
      int x = findSet(i), y = findSet(j);
      if (rank[x] > rank[y])
        p[y] = x, rank[x] += rank[y];
      else {
        p[x] = y;
        rank[y] += rank[x];
      }
    }
  }
};
class RMQ {
 public:
  struct node {
    int mn, mx, l, r;
  };
  vector<int> h;
  vector<node> st;
  bool is_intersection(int l, int r, int ll, int rr) {
    if (r < ll || rr < l) return 0;
    return 1;
  }
  RMQ(vector<int> a) {
    h = a;
    st.resize(4 * h.size());
    build(0, h.size() - 1);
  }
  void build(int l, int r, int k = 0) {
    st[k].l = l, st[k].r = r;
    if (l == r) {
      st[k].mx = st[k].mn = l;
      return;
    }
    build(l, (l + r) / 2, 2 * k + 1);
    build((l + r) / 2 + 1, r, 2 * k + 2);
    if (h[st[2 * k + 1].mn] <= h[st[2 * k + 2].mn])
      st[k].mn = st[2 * k + 1].mn;
    else
      st[k].mn = st[2 * k + 2].mn;
    if (h[st[2 * k + 1].mx] >= h[st[2 * k + 2].mx])
      st[k].mx = st[2 * k + 1].mx;
    else
      st[k].mx = st[2 * k + 2].mx;
  }
  int minquery(int l, int r, int k = 0) {
    if (l > r) return 1000000000;
    int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2;
    if (ll >= l && rr <= r) return st[k].mn;
    int ans = l;
    if (!(r < ll || mid < l)) ans = minquery(l, r, 2 * k + 1);
    if (!(r < mid + 1 || rr < l)) {
      if (h[ans] > h[minquery(l, r, 2 * k + 2)])
        ans = minquery(l, r, 2 * k + 2);
    }
    return ans;
  }
  int maxquery(int l, int r, int k = 0) {
    if (l > r) return -1000000000;
    int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2;
    if (ll >= l && rr <= r) return st[k].mx;
    int ans = l;
    if (!(r < ll || mid < l)) ans = maxquery(l, r, 2 * k + 1);
    if (!(r < mid + 1 || rr < l)) {
      if (h[ans] < h[maxquery(l, r, 2 * k + 2)])
        ans = maxquery(l, r, 2 * k + 2);
    }
    return ans;
  }
  void update(int id, int val, int k = 0) {
    int l = st[k].l, r = st[k].r, mid = (l + r) / 2;
    if (l == r) {
      h[l] = val;
      return;
    }
    if (id >= l && id <= mid) update(id, val, 2 * k + 1);
    if (mid + 1 <= id && id <= r) update(id, val, 2 * k + 2);
    if (h[st[2 * k + 1].mn] <= h[st[2 * k + 2].mn])
      st[k].mn = st[2 * k + 1].mn;
    else
      st[k].mn = st[2 * k + 2].mn;
    if (h[st[2 * k + 1].mx] >= h[st[2 * k + 2].mx])
      st[k].mx = st[2 * k + 1].mx;
    else
      st[k].mx = st[2 * k + 2].mx;
  }
};
class LAZY {
 public:
  struct node {
    int l, r, lazy = 0;
    long long int lazyval = 0;
    long long int sum = 0;
  };
  vector<node> st;
  vector<long long int> h;
  LAZY(vector<long long int> a) {
    h = a;
    st.resize(4 * h.size());
    cst(0, h.size() - 1);
  }
  int intersectiontype1(int l, int r, int ll, int rr) {
    if (r < ll || rr < l) return 0;
    return 1;
  }
  void cst(int l, int r, int k = 0) {
    st[k].l = l, st[k].r = r;
    if (l == r) {
      st[k].sum = h[l];
      return;
    }
    cst(l, (l + r) / 2, 2 * k + 1);
    cst((l + r) / 2 + 1, r, 2 * k + 2);
    st[k].sum = st[2 * k + 1].sum + st[2 * k + 2].sum;
  }
  void shift(int k) {
    st[k].sum += (st[k].r - st[k].l + 1) * st[k].lazyval;
    if (st[k].l != st[k].r) {
      st[2 * k + 1].lazyval += st[k].lazyval;
      st[2 * k + 2].lazyval += st[k].lazyval;
      st[2 * k + 1].lazy = st[2 * k + 1].lazy = 1;
      st[2 * k + 2].lazy = st[2 * k + 2].lazy = 1;
    }
    st[k].lazyval = 0;
    st[k].lazy = 0;
  }
  long long int query(int l, int r, int k = 0) {
    if (st[k].lazy != 0) shift(k);
    int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2;
    if (ll >= l && rr <= r) return st[k].sum;
    long long int ans = 0;
    if (intersectiontype1(ll, mid, l, r) == 1) ans = query(l, r, 2 * k + 1);
    if (intersectiontype1(1 + mid, rr, l, r) == 1)
      ans += query(l, r, 2 * k + 2);
    return ans;
  }
  void update(int l, int r, long long int x, int k = 0) {
    if (l > r) return;
    int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2;
    if (ll >= l && rr <= r) {
      st[k].lazyval += x;
      st[k].lazy = 1;
      return;
    }
    if (st[k].lazy != 0) shift(k);
    if (st[k].l == st[k].r) return;
    if (intersectiontype1(ll, mid, l, r) == 1) update(l, r, x, 2 * k + 1);
    if (intersectiontype1(mid + 1, rr, l, r) == 1) update(l, r, x, 2 * k + 2);
    if (st[2 * k + 1].lazy != 0) shift(2 * k + 1);
    if (st[2 * k + 2].lazy != 0) shift(2 * k + 2);
    st[k].sum = st[2 * k + 1].sum + st[2 * k + 2].sum;
  }
};
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  if (res < 0) res += 1000000007;
  return res;
}
long long int modInverse(long long int a, long long int m) {
  long long int m0 = m;
  long long int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
void DEBUG_ARR(vector<int> a) {
  for (long long int i = 0; i < a.size(); i++) cout << a[i] << " ";
  cout << "\n";
}
vector<int> max_left_border_without_equality(vector<int> a) {
  int n = a.size();
  vector<int> ta, al(n);
  for (long long int i = 0; i < n; i++) {
    if (ta.size() == 0) {
      ta.push_back(i);
      al[i] = i;
    } else {
      while (a[i] > a[ta[ta.size() - 1]]) {
        ta.pop_back();
        if (ta.size() == 0) break;
      }
      if (ta.size() == 0) {
        ta.push_back(i);
        al[i] = 0;
      } else {
        al[i] = ta[ta.size() - 1] + 1;
        ta.push_back(i);
      }
    }
  }
  return al;
}
vector<int> max_left_border_with_equality(vector<int> a) {
  int n = a.size();
  vector<int> ta, al(n);
  for (long long int i = 0; i < n; i++) {
    if (ta.size() == 0) {
      ta.push_back(i);
      al[i] = i;
    } else {
      while (a[i] >= a[ta[ta.size() - 1]]) {
        ta.pop_back();
        if (ta.size() == 0) break;
      }
      if (ta.size() == 0) {
        ta.push_back(i);
        al[i] = 0;
      } else {
        al[i] = ta[ta.size() - 1] + 1;
        ta.push_back(i);
      }
    }
  }
  return al;
}
vector<int> min_left_border_without_equality(vector<int> a) {
  int n = a.size();
  vector<int> ta, al(n);
  for (long long int i = 0; i < n; i++) {
    if (ta.size() == 0) {
      ta.push_back(i);
      al[i] = i;
    } else {
      while (a[i] < a[ta[ta.size() - 1]]) {
        ta.pop_back();
        if (ta.size() == 0) break;
      }
      if (ta.size() == 0) {
        ta.push_back(i);
        al[i] = 0;
      } else {
        al[i] = ta[ta.size() - 1] + 1;
        ta.push_back(i);
      }
    }
  }
  return al;
}
vector<int> min_left_border_with_equality(vector<int> a) {
  int n = a.size();
  vector<int> ta, al(n);
  for (long long int i = 0; i < n; i++) {
    if (ta.size() == 0) {
      ta.push_back(i);
      al[i] = i;
    } else {
      while (a[i] <= a[ta[ta.size() - 1]]) {
        ta.pop_back();
        if (ta.size() == 0) break;
      }
      if (ta.size() == 0) {
        ta.push_back(i);
        al[i] = 0;
      } else {
        al[i] = ta[ta.size() - 1] + 1;
        ta.push_back(i);
      }
    }
  }
  return al;
}
vector<int> max_right_border_without_equality(vector<int> a) {
  int n = a.size();
  reverse(a.begin(), a.end());
  vector<int> ans = max_left_border_without_equality(a);
  reverse(ans.begin(), ans.end());
  for (long long int i = 0; i < n; i++) ans[i] = n - 1 - ans[i];
  return ans;
}
vector<int> max_right_border_with_equality(vector<int> a) {
  int n = a.size();
  reverse(a.begin(), a.end());
  vector<int> ans = max_left_border_with_equality(a);
  reverse(ans.begin(), ans.end());
  for (long long int i = 0; i < n; i++) ans[i] = n - 1 - ans[i];
  return ans;
}
vector<int> min_right_border_without_equality(vector<int> a) {
  int n = a.size();
  reverse(a.begin(), a.end());
  vector<int> ans = min_left_border_without_equality(a);
  reverse(ans.begin(), ans.end());
  for (long long int i = 0; i < n; i++) ans[i] = n - 1 - ans[i];
  return ans;
}
vector<int> min_right_border_with_equality(vector<int> a) {
  int n = a.size();
  reverse(a.begin(), a.end());
  vector<int> ans = min_left_border_with_equality(a);
  reverse(ans.begin(), ans.end());
  for (long long int i = 0; i < n; i++) ans[i] = n - 1 - ans[i];
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  vector<int> al, ar, al2, ar2;
  al = max_left_border_without_equality(a);
  ar = max_right_border_with_equality(a);
  al2 = min_left_border_without_equality(a);
  ar2 = min_right_border_with_equality(a);
  long long int ans = 0;
  int pos = 0;
  while (pos != n) {
    long long int l = al[pos], r = ar[pos];
    int temp = a[pos];
    ans += (r - pos + 1) * (pos - l + 1) * (long long int)temp;
    l = al2[pos], r = ar2[pos];
    ans -= (r - pos + 1) * (pos - l + 1) * (long long int)temp;
    pos++;
  }
  cout << ans;
  return 0;
}

### Prompt

In cpp, your task is to solve the following problem:

You are given an array a consisting of n elements. The imbalance value of some subsegment of this array is the difference between the maximum and minimum element from this segment. The imbalance value of the array is the sum of imbalance values of all subsegments of this array.

For example, the imbalance value of array [1, 4, 1] is 9, because there are 6 different subsegments of this array: 

  * [1] (from index 1 to index 1), imbalance value is 0; 
  * [1, 4] (from index 1 to index 2), imbalance value is 3; 
  * [1, 4, 1] (from index 1 to index 3), imbalance value is 3; 
  * [4] (from index 2 to index 2), imbalance value is 0; 
  * [4, 1] (from index 2 to index 3), imbalance value is 3; 
  * [1] (from index 3 to index 3), imbalance value is 0; 



You have to determine the imbalance value of the array a.

Input

The first line contains one integer n (1 ≤ n ≤ 106) — size of the array a.

The second line contains n integers a1, a2... an (1 ≤ ai ≤ 106) — elements of the array.

Output

Print one integer — the imbalance value of a.

Example

Input

3
1 4 1


Output

9

### Response

```cpp
#include <bits/stdc++.h>
#pragma GCC optimize("-O2")
using namespace std;
long long int tmod(long long int x, long long int m) { return (x % m + m) % m; }
class UnionFind {
 public:
  vector<int> p, rank;
  UnionFind(int N) {
    rank.assign(N, 1);
    p.assign(N, 0);
    for (int i = 0; i < N; i++) p[i] = i;
  }
  int findSet(int i) { return (p[i] == i) ? i : (p[i] = findSet(p[i])); }
  bool isSameSet(int i, int j) { return findSet(i) == findSet(j); }
  void unionSet(int i, int j) {
    if (!isSameSet(i, j)) {
      int x = findSet(i), y = findSet(j);
      if (rank[x] > rank[y])
        p[y] = x, rank[x] += rank[y];
      else {
        p[x] = y;
        rank[y] += rank[x];
      }
    }
  }
};
class RMQ {
 public:
  struct node {
    int mn, mx, l, r;
  };
  vector<int> h;
  vector<node> st;
  bool is_intersection(int l, int r, int ll, int rr) {
    if (r < ll || rr < l) return 0;
    return 1;
  }
  RMQ(vector<int> a) {
    h = a;
    st.resize(4 * h.size());
    build(0, h.size() - 1);
  }
  void build(int l, int r, int k = 0) {
    st[k].l = l, st[k].r = r;
    if (l == r) {
      st[k].mx = st[k].mn = l;
      return;
    }
    build(l, (l + r) / 2, 2 * k + 1);
    build((l + r) / 2 + 1, r, 2 * k + 2);
    if (h[st[2 * k + 1].mn] <= h[st[2 * k + 2].mn])
      st[k].mn = st[2 * k + 1].mn;
    else
      st[k].mn = st[2 * k + 2].mn;
    if (h[st[2 * k + 1].mx] >= h[st[2 * k + 2].mx])
      st[k].mx = st[2 * k + 1].mx;
    else
      st[k].mx = st[2 * k + 2].mx;
  }
  int minquery(int l, int r, int k = 0) {
    if (l > r) return 1000000000;
    int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2;
    if (ll >= l && rr <= r) return st[k].mn;
    int ans = l;
    if (!(r < ll || mid < l)) ans = minquery(l, r, 2 * k + 1);
    if (!(r < mid + 1 || rr < l)) {
      if (h[ans] > h[minquery(l, r, 2 * k + 2)])
        ans = minquery(l, r, 2 * k + 2);
    }
    return ans;
  }
  int maxquery(int l, int r, int k = 0) {
    if (l > r) return -1000000000;
    int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2;
    if (ll >= l && rr <= r) return st[k].mx;
    int ans = l;
    if (!(r < ll || mid < l)) ans = maxquery(l, r, 2 * k + 1);
    if (!(r < mid + 1 || rr < l)) {
      if (h[ans] < h[maxquery(l, r, 2 * k + 2)])
        ans = maxquery(l, r, 2 * k + 2);
    }
    return ans;
  }
  void update(int id, int val, int k = 0) {
    int l = st[k].l, r = st[k].r, mid = (l + r) / 2;
    if (l == r) {
      h[l] = val;
      return;
    }
    if (id >= l && id <= mid) update(id, val, 2 * k + 1);
    if (mid + 1 <= id && id <= r) update(id, val, 2 * k + 2);
    if (h[st[2 * k + 1].mn] <= h[st[2 * k + 2].mn])
      st[k].mn = st[2 * k + 1].mn;
    else
      st[k].mn = st[2 * k + 2].mn;
    if (h[st[2 * k + 1].mx] >= h[st[2 * k + 2].mx])
      st[k].mx = st[2 * k + 1].mx;
    else
      st[k].mx = st[2 * k + 2].mx;
  }
};
class LAZY {
 public:
  struct node {
    int l, r, lazy = 0;
    long long int lazyval = 0;
    long long int sum = 0;
  };
  vector<node> st;
  vector<long long int> h;
  LAZY(vector<long long int> a) {
    h = a;
    st.resize(4 * h.size());
    cst(0, h.size() - 1);
  }
  int intersectiontype1(int l, int r, int ll, int rr) {
    if (r < ll || rr < l) return 0;
    return 1;
  }
  void cst(int l, int r, int k = 0) {
    st[k].l = l, st[k].r = r;
    if (l == r) {
      st[k].sum = h[l];
      return;
    }
    cst(l, (l + r) / 2, 2 * k + 1);
    cst((l + r) / 2 + 1, r, 2 * k + 2);
    st[k].sum = st[2 * k + 1].sum + st[2 * k + 2].sum;
  }
  void shift(int k) {
    st[k].sum += (st[k].r - st[k].l + 1) * st[k].lazyval;
    if (st[k].l != st[k].r) {
      st[2 * k + 1].lazyval += st[k].lazyval;
      st[2 * k + 2].lazyval += st[k].lazyval;
      st[2 * k + 1].lazy = st[2 * k + 1].lazy = 1;
      st[2 * k + 2].lazy = st[2 * k + 2].lazy = 1;
    }
    st[k].lazyval = 0;
    st[k].lazy = 0;
  }
  long long int query(int l, int r, int k = 0) {
    if (st[k].lazy != 0) shift(k);
    int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2;
    if (ll >= l && rr <= r) return st[k].sum;
    long long int ans = 0;
    if (intersectiontype1(ll, mid, l, r) == 1) ans = query(l, r, 2 * k + 1);
    if (intersectiontype1(1 + mid, rr, l, r) == 1)
      ans += query(l, r, 2 * k + 2);
    return ans;
  }
  void update(int l, int r, long long int x, int k = 0) {
    if (l > r) return;
    int ll = st[k].l, rr = st[k].r, mid = (ll + rr) / 2;
    if (ll >= l && rr <= r) {
      st[k].lazyval += x;
      st[k].lazy = 1;
      return;
    }
    if (st[k].lazy != 0) shift(k);
    if (st[k].l == st[k].r) return;
    if (intersectiontype1(ll, mid, l, r) == 1) update(l, r, x, 2 * k + 1);
    if (intersectiontype1(mid + 1, rr, l, r) == 1) update(l, r, x, 2 * k + 2);
    if (st[2 * k + 1].lazy != 0) shift(2 * k + 1);
    if (st[2 * k + 2].lazy != 0) shift(2 * k + 2);
    st[k].sum = st[2 * k + 1].sum + st[2 * k + 2].sum;
  }
};
long long int power(long long int x, long long int y) {
  long long int res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y = y >> 1;
    x = (x * x) % 1000000007;
  }
  if (res < 0) res += 1000000007;
  return res;
}
long long int modInverse(long long int a, long long int m) {
  long long int m0 = m;
  long long int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
void DEBUG_ARR(vector<int> a) {
  for (long long int i = 0; i < a.size(); i++) cout << a[i] << " ";
  cout << "\n";
}
vector<int> max_left_border_without_equality(vector<int> a) {
  int n = a.size();
  vector<int> ta, al(n);
  for (long long int i = 0; i < n; i++) {
    if (ta.size() == 0) {
      ta.push_back(i);
      al[i] = i;
    } else {
      while (a[i] > a[ta[ta.size() - 1]]) {
        ta.pop_back();
        if (ta.size() == 0) break;
      }
      if (ta.size() == 0) {
        ta.push_back(i);
        al[i] = 0;
      } else {
        al[i] = ta[ta.size() - 1] + 1;
        ta.push_back(i);
      }
    }
  }
  return al;
}
vector<int> max_left_border_with_equality(vector<int> a) {
  int n = a.size();
  vector<int> ta, al(n);
  for (long long int i = 0; i < n; i++) {
    if (ta.size() == 0) {
      ta.push_back(i);
      al[i] = i;
    } else {
      while (a[i] >= a[ta[ta.size() - 1]]) {
        ta.pop_back();
        if (ta.size() == 0) break;
      }
      if (ta.size() == 0) {
        ta.push_back(i);
        al[i] = 0;
      } else {
        al[i] = ta[ta.size() - 1] + 1;
        ta.push_back(i);
      }
    }
  }
  return al;
}
vector<int> min_left_border_without_equality(vector<int> a) {
  int n = a.size();
  vector<int> ta, al(n);
  for (long long int i = 0; i < n; i++) {
    if (ta.size() == 0) {
      ta.push_back(i);
      al[i] = i;
    } else {
      while (a[i] < a[ta[ta.size() - 1]]) {
        ta.pop_back();
        if (ta.size() == 0) break;
      }
      if (ta.size() == 0) {
        ta.push_back(i);
        al[i] = 0;
      } else {
        al[i] = ta[ta.size() - 1] + 1;
        ta.push_back(i);
      }
    }
  }
  return al;
}
vector<int> min_left_border_with_equality(vector<int> a) {
  int n = a.size();
  vector<int> ta, al(n);
  for (long long int i = 0; i < n; i++) {
    if (ta.size() == 0) {
      ta.push_back(i);
      al[i] = i;
    } else {
      while (a[i] <= a[ta[ta.size() - 1]]) {
        ta.pop_back();
        if (ta.size() == 0) break;
      }
      if (ta.size() == 0) {
        ta.push_back(i);
        al[i] = 0;
      } else {
        al[i] = ta[ta.size() - 1] + 1;
        ta.push_back(i);
      }
    }
  }
  return al;
}
vector<int> max_right_border_without_equality(vector<int> a) {
  int n = a.size();
  reverse(a.begin(), a.end());
  vector<int> ans = max_left_border_without_equality(a);
  reverse(ans.begin(), ans.end());
  for (long long int i = 0; i < n; i++) ans[i] = n - 1 - ans[i];
  return ans;
}
vector<int> max_right_border_with_equality(vector<int> a) {
  int n = a.size();
  reverse(a.begin(), a.end());
  vector<int> ans = max_left_border_with_equality(a);
  reverse(ans.begin(), ans.end());
  for (long long int i = 0; i < n; i++) ans[i] = n - 1 - ans[i];
  return ans;
}
vector<int> min_right_border_without_equality(vector<int> a) {
  int n = a.size();
  reverse(a.begin(), a.end());
  vector<int> ans = min_left_border_without_equality(a);
  reverse(ans.begin(), ans.end());
  for (long long int i = 0; i < n; i++) ans[i] = n - 1 - ans[i];
  return ans;
}
vector<int> min_right_border_with_equality(vector<int> a) {
  int n = a.size();
  reverse(a.begin(), a.end());
  vector<int> ans = min_left_border_with_equality(a);
  reverse(ans.begin(), ans.end());
  for (long long int i = 0; i < n; i++) ans[i] = n - 1 - ans[i];
  return ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (long long int i = 0; i < n; i++) cin >> a[i];
  vector<int> al, ar, al2, ar2;
  al = max_left_border_without_equality(a);
  ar = max_right_border_with_equality(a);
  al2 = min_left_border_without_equality(a);
  ar2 = min_right_border_with_equality(a);
  long long int ans = 0;
  int pos = 0;
  while (pos != n) {
    long long int l = al[pos], r = ar[pos];
    int temp = a[pos];
    ans += (r - pos + 1) * (pos - l + 1) * (long long int)temp;
    l = al2[pos], r = ar2[pos];
    ans -= (r - pos + 1) * (pos - l + 1) * (long long int)temp;
    pos++;
  }
  cout << ans;
  return 0;
}

```