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 ll = long long;
using namespace std;
namespace Debug {
template <class A, class B>
ostream &operator<<(ostream &out, pair<A, B> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}
template <class T>
ostream &operator<<(ostream &out, vector<T> &v) {
  out << "{";
  string sep;
  for (T el : v) out << sep << el, sep = ", ";
  out << "}";
  return out;
}
void debug_out() { cerr << endl; }
template <class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
  cerr << ' ' << head;
  debug_out(tail...);
}
}  // namespace Debug
using namespace Debug;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n;
  string s;
  cin >> n;
  cin >> s;
  vector<int> bal(n);
  bal[0] = (s[0] == '(' ? 1 : -1);
  for (int i = 1; i < n; i++) bal[i] = bal[i - 1] + (s[i] == '(' ? 1 : -1);
  if (bal.back() != 0) return cout << "0\n1 1\n", 0;
  vector<vector<int>> cnt(2 * n + 1);
  for (int i = 0; i < n; i++) cnt[bal[i] + n].push_back(i);
  for (int i = 0; i < 2 * n + 1; i++)
    ;
  int mn_bal = 0;
  while (cnt[mn_bal].size() == 0) mn_bal++;
  ;
  ;
  int ans = cnt[mn_bal].size();
  int pos1 = 0, pos2 = 0;
  vector<pair<int, int>> right(n, {-1, -1}), left(n, {-1, -1});
  if (s[0] == '(')
    left[0].first = 0;
  else
    left[0].second = 0;
  for (int i = 1; i < n; i++) {
    left[i] = left[i - 1];
    if (s[i] == '(')
      left[i].first = i;
    else
      left[i].second = i;
  }
  if (s[n - 1] == '(')
    right[n - 1].first = n - 1;
  else
    right[n - 1].second = n - 1;
  for (int i = n - 2; i >= 0; i--) {
    right[i] = right[i + 1];
    if (s[i] == '(')
      right[i].first = i;
    else
      right[i].second = i;
  };
  ;
  vector<int> bad = {-1};
  for (auto i : cnt[mn_bal]) bad.push_back(i);
  for (auto i : cnt[mn_bal + 1]) bad.push_back(i);
  bad.push_back(n);
  sort(bad.begin(), bad.end());
  ;
  for (int i = 1; i < bad.size(); i++) {
    int L = bad[i - 1] + 1, R = bad[i] - 1;
    if (L > R) continue;
    ;
    L = right[L].first;
    R = left[R + 1].second;
    ;
    if (L > R || L == -1 || R == -1) continue;
    int cur_ans = cnt[mn_bal].size();
    cur_ans += lower_bound(cnt[mn_bal + 2].begin(), cnt[mn_bal + 2].end(), R) -
               lower_bound(cnt[mn_bal + 2].begin(), cnt[mn_bal + 2].end(), L);
    ;
    if (cur_ans > ans) ans = cur_ans, pos1 = L, pos2 = R;
  }
  bad = {-1};
  for (auto i : cnt[mn_bal]) bad.push_back(i);
  bad.push_back(n);
  for (int i = 1; i < bad.size(); i++) {
    int L = bad[i - 1] + 1, R = bad[i] - 1;
    if (L > R) continue;
    L = right[L].first;
    R = left[R + 1].second;
    if (L > R || L == -1 || R == -1) continue;
    int cur_ans =
        lower_bound(cnt[mn_bal + 1].begin(), cnt[mn_bal + 1].end(), R) -
        lower_bound(cnt[mn_bal + 1].begin(), cnt[mn_bal + 1].end(), L);
    if (cur_ans > ans) ans = cur_ans, pos1 = L, pos2 = R;
  }
  int L = left[cnt[mn_bal][0]].second;
  int R = -1;
  if (cnt[mn_bal].back() != n - 1) R = right[cnt[mn_bal].back() + 1].first;
  if (L != -1 && R != -1 && L < R) {
    int cur_ans;
    if (cnt[mn_bal + 1].size() == 0 ||
        (L <= cnt[mn_bal + 1][0] && cnt[mn_bal + 1].back() < R))
      cur_ans =
          cnt[mn_bal].size() + cnt[mn_bal + 2].size() -
          (lower_bound(cnt[mn_bal + 2].begin(), cnt[mn_bal + 2].end(), R) -
           lower_bound(cnt[mn_bal + 2].begin(), cnt[mn_bal + 2].end(), L));
    else
      cur_ans =
          cnt[mn_bal + 1].size() -
          (lower_bound(cnt[mn_bal + 1].begin(), cnt[mn_bal + 1].end(), R) -
           lower_bound(cnt[mn_bal + 1].begin(), cnt[mn_bal + 1].end(), L));
    if (cur_ans > ans) ans = cur_ans, pos1 = L, pos2 = R;
  }
  if (cnt[mn_bal + 1].size() != 0 &&
      max(cnt[mn_bal].back(), cnt[mn_bal + 1].back()) != n - 1) {
    L = left[min(cnt[mn_bal][0], cnt[mn_bal + 1][0])].second;
    R = right[max(cnt[mn_bal].back(), cnt[mn_bal + 1].back()) + 1].first;
    int cur_ans = 0;
    if (L != -1 && R != -1 && L < R)
      cur_ans =
          cnt[mn_bal].size() + cnt[mn_bal + 2].size() -
          (lower_bound(cnt[mn_bal + 2].begin(), cnt[mn_bal + 2].end(), R) -
           lower_bound(cnt[mn_bal + 2].begin(), cnt[mn_bal + 2].end(), L));
    if (cur_ans > ans) ans = cur_ans, pos1 = L, pos2 = R;
  }
  cout << ans << '\n' << pos1 + 1 << ' ' << pos2 + 1 << '\n';
}