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;
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (auto i = begin(v); i != end(v); i++)
    os << *i << (i == end(v) - 1 ? "" : " ");
  return os;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto i = begin(v); i != end(v); i++) is >> *i;
  return is;
}
int get_count(string s) {
  vector<int> vec(s.size());
  int min_val = 1;
  for (int i = 0; i < s.size(); i++) {
    vec[i] = s[i] == '(' ? 1 : -1;
    if (i > 0) vec[i] += vec[i - 1];
    min_val = min(min_val, vec[i]);
  }
  int cnt = 0;
  for (int x : vec)
    if (x == min_val) cnt++;
  return cnt;
}
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> vec(s.size());
  int min_val = n;
  int last_close = -1;
  for (int i = 0; i < s.size(); i++) {
    vec[i] = s[i] == '(' ? 1 : -1;
    if (i > 0) vec[i] += vec[i - 1];
    min_val = min(min_val, vec[i]);
    if (s[i] == ')') last_close = i;
  }
  if (vec.back() != 0) {
    cout << "0\n1 1";
    return 0;
  }
  int ans = 0;
  int left_open = -1;
  int diff = 0;
  int best_score = 0;
  pair<int, int> repl = {0, 0};
  for (int i = 0; i < n; i++) {
    bool stop = abs(vec[i] - min_val) <= 1 || i == last_close;
    if (stop && left_open > -1) {
      if (diff > best_score) {
        best_score = diff;
        repl = {left_open, i};
      }
      left_open = -1;
    }
    if (stop) continue;
    bool start = s[i] == '(';
    if (start && left_open == -1) {
      diff = 0;
      left_open = i;
    }
    if (left_open > -1) {
      if (abs(vec[i] - min_val) == 2) diff++;
    }
  }
  best_score += get_count(s);
  diff = 0;
  left_open = -1;
  for (int i = 0; i < n; i++) {
    bool stop = abs(vec[i] - min_val) <= 0 || i == last_close;
    if (stop && left_open > -1) {
      if (diff > best_score) {
        best_score = diff;
        repl = {left_open, i};
      }
      left_open = -1;
    }
    if (stop) continue;
    bool start = s[i] == '(';
    if (start && left_open == -1) {
      diff = 0;
      left_open = i;
    }
    if (left_open > -1) {
      if (abs(vec[i] - min_val) == 1) diff++;
    }
  }
  int first_pos = -1;
  int last_pos = -1;
  bool on = false;
  for (int i = 0; i < n; i++) {
    int d = abs(vec[i] - min_val);
    if (d == 0 && s[i] == ')' && first_pos < 0) {
      first_pos = i;
    }
    if (d == 0 && first_pos >= 0) on = true;
    if (d > 0 && s[i] == '(' && on) {
      on = false;
      last_pos = i;
    }
  }
  if (on) last_pos = -1;
  int first_pos1 = -1;
  int last_pos1 = -1;
  on = false;
  for (int i = 0; i < n; i++) {
    int d = abs(vec[i] - min_val);
    if (d <= 1 && s[i] == ')' && first_pos1 < 0) {
      first_pos1 = i;
    }
    if (d <= 1 && first_pos1 >= 0) on = true;
    if (d > 1 && s[i] == '(' && on) {
      on = false;
      last_pos1 = i;
    }
  }
  int a_sub = best_score;
  int a_add1 = -1;
  int a_add2 = -1;
  if (first_pos >= 0 && last_pos >= 0) {
    string str = s;
    swap(str[first_pos], str[last_pos]);
    a_add1 = get_count(str);
  }
  if (first_pos1 >= 0 && last_pos1 >= 0) {
    string str = s;
    swap(str[first_pos1], str[last_pos1]);
    a_add2 = get_count(str);
  }
  if (n == 300000 && a_sub == 2) {
  }
  if (a_sub >= a_add1 && a_sub >= a_add2) {
    cout << a_sub << "\n" << repl.first + 1 << " " << repl.second + 1;
  } else if (a_add1 >= a_sub && a_add1 >= a_add2) {
    cout << a_add1 << "\n  " << first_pos + 1 << " " << last_pos + 1;
  } else {
    cout << a_add2 << "\n   " << first_pos1 + 1 << " " << last_pos1 + 1;
  }
  return 0;
}