Problem: This is a harder version of the problem. In this version, n ≤ 300 000.

Vasya is an experienced developer of programming competitions' problems. As all great minds at some time, Vasya faced a creative crisis. To improve the situation, Petya gifted him a string consisting of opening and closing brackets only. Petya believes, that the beauty of the bracket string is a number of its cyclical shifts, which form a correct bracket sequence.

To digress from his problems, Vasya decided to select two positions of the string (not necessarily distinct) and swap characters located at this positions with each other. Vasya will apply this operation exactly once. He is curious what is the maximum possible beauty he can achieve this way. Please help him.

We remind that bracket sequence s is called correct if: 

  * s is empty; 
  * s is equal to "(t)", where t is correct bracket sequence; 
  * s is equal to t_1 t_2, i.e. concatenation of t_1 and t_2, where t_1 and t_2 are correct bracket sequences. 



For example, "(()())", "()" are correct, while ")(" and "())" are not.

The cyclical shift of the string s of length n by k (0 ≤ k < n) is a string formed by a concatenation of the last k symbols of the string s with the first n - k symbols of string s. For example, the cyclical shift of string "(())()" by 2 equals "()(())".

Cyclical shifts i and j are considered different, if i ≠ j.

Input

The first line contains an integer n (1 ≤ n ≤ 300 000), the length of the string.

The second line contains a string, consisting of exactly n characters, where each of the characters is either "(" or ")".

Output

The first line should contain a single integer — the largest beauty of the string, which can be achieved by swapping some two characters.

The second line should contain integers l and r (1 ≤ l, r ≤ n) — the indices of two characters, which should be swapped in order to maximize the string's beauty.

In case there are several possible swaps, print any of them.

Examples

Input


10
()()())(()


Output


5
8 7


Input


12
)(()(()())()


Output


4
5 10


Input


6
)))(()


Output


0
1 1

Note

In the first example, we can swap 7-th and 8-th character, obtaining a string "()()()()()". The cyclical shifts by 0, 2, 4, 6, 8 of this string form a correct bracket sequence.

In the second example, after swapping 5-th and 10-th character, we obtain a string ")(())()()(()". The cyclical shifts by 11, 7, 5, 3 of this string form a correct bracket sequence.

In the third example, swap of any two brackets results in 0 cyclical shifts being correct bracket sequences. 

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
pair<int, int> mrg(pair<int, int> a, pair<int, int> b) {
  pair<int, int> res(min(a.first, b.first), 0);
  if (a.first == res.first) res.second += a.second;
  if (b.first == res.first) res.second += b.second;
  return res;
}
struct segTree {
  int n;
  vector<pair<int, int> > tree;
  segTree(int n) : n(n), tree(4 * n, {300005, 0}) {}
  void treeUpdate(int node, int i, int j, int x, int val) {
    int mid = (i + j) >> 1;
    if (i == j && i == x) {
      tree[node] = {val, 1};
      return;
    }
    if (i > x || j < x) return;
    treeUpdate(2 * node, i, mid, x, val);
    treeUpdate(2 * node + 1, mid + 1, j, x, val);
    tree[node] = mrg(tree[2 * node], tree[2 * node + 1]);
    return;
  }
  void update(int idx, int v) { treeUpdate(1, 1, n, idx, v); }
  pair<int, int> treeQuery(int node, int i, int j, int u, int v) {
    int mid = (i + j) >> 1;
    if (i >= u && j <= v) return tree[node];
    if (i > v || j < u) return {300005, 0};
    return mrg(treeQuery(2 * node, i, mid, u, v),
               treeQuery(2 * node + 1, mid + 1, j, u, v));
  }
  pair<int, int> query(int l, int r) { return treeQuery(1, 1, n, l, r); }
};
char s[300005];
int cur[300005];
int main() {
  int n;
  scanf("%d %s", &n, s + 1);
  int a = 0;
  for (int i = 1; i <= n; i++) a += (s[i] == '(');
  if (2 * a != n) {
    printf("0\n1 1\n");
    return 0;
  }
  segTree tree(n);
  for (int i = 1; i <= n; i++) {
    cur[i] = cur[i - 1];
    if (s[i] == '(')
      cur[i]++;
    else
      cur[i]--;
    tree.update(i, cur[i]);
  }
  pair<int, int> mot = tree.query(1, n);
  int mn = mot.first, ase = mot.second;
  int ans = ase, ansa = 1, ansb = 1;
  vector<int> lit, med;
  for (int i = 1; i <= n; i++) {
    if (cur[i] == mn)
      lit.push_back(i);
    else if (s[i] == ')' && cur[i] == mn + 1)
      med.push_back(i);
  }
  for (int i = n; i; i--) {
    if (s[i] == '(') continue;
    if (lit.empty() || lit.back() < i) lit.push_back(i);
    if (med.empty() || med.back() < i) med.push_back(i);
    break;
  }
  for (int i = 1; i < lit.back(); i++) {
    if (s[i] == ')') continue;
    int j = upper_bound(lit.begin(), lit.end(), i) - lit.begin();
    pair<int, int> p = tree.query(i, lit[j] - 1);
    if (p.first == mn + 1) {
      if (ans < p.second) ans = p.second, ansa = i, ansb = lit[j];
    } else if (p.first == mn + 2) {
      if (ans < p.second + ase) ans = p.second + ase, ansa = i, ansb = lit[j];
    }
    int k = upper_bound(med.begin(), med.end(), i) - med.begin();
    if (med[k] > lit[j]) continue;
    p = tree.query(i, med[k] - 1);
    if (p.first == mn + 1) {
      if (ans < p.second) ans = p.second, ansa = i, ansb = med[k];
    } else if (p.first == mn + 2) {
      if (ans < p.second + ase) ans = p.second + ase, ansa = i, ansb = med[k];
    }
  }
  int st = -1, ed = -1;
  for (int i = 1; i <= n; i++) {
    if (cur[i] == mn) {
      st = i;
      break;
    }
  }
  for (int i = n; i; i--) {
    if (cur[i] == mn) {
      ed = i;
      break;
    }
  }
  if (ed < n) {
    int aro = 0;
    for (int i = 1; i < st; i++) aro += (cur[i] == mn + 1);
    for (int i = n; i > ed; i--) aro += (cur[i] == mn + 1);
    if (ans < aro) ans = aro, ansa = st, ansb = ed + 1;
  }
  for (int i = 1; i <= n; i++) {
    if (cur[i] == mn + 1) {
      st = i;
      break;
    }
  }
  for (int i = n; i; i--) {
    if (cur[i] == mn + 1) {
      ed = i;
      break;
    }
  }
  if (s[st] == ')' && ed < n && s[ed + 1] == '(') {
    int aro = 0;
    for (int i = 1; i < st; i++) aro += (cur[i] == mn + 2);
    for (int i = n; i > ed; i--) aro += (cur[i] == mn + 2);
    for (int i = st; i <= ed; i++) aro += (cur[i] == mn);
    if (ans < aro) ans = aro, ansa = st, ansb = ed + 1;
  }
  printf("%d\n%d %d\n", ans, ansa, ansb);
  return 0;
}