#include <bits/stdc++.h>
using namespace std;
int dp[205][205][205];
int total, a[205], b[205];
int n;
int coinch(int thick, int w, int i) {
  if (i > n - 1) return thick;
  int &ret = dp[i][thick][w];
  if (ret != -1) return ret;
  ret = total;
  int ret1 = total, ret2 = total;
  if (thick - a[i] >= w + b[i]) ret1 = coinch(thick - a[i], w + b[i], i + 1);
  ret2 = coinch(thick, w, i + 1);
  return min(ret1, ret2);
}
int main() {
  memset(dp, -1, sizeof dp);
  total = 0;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    total += a[i];
  }
  int result = coinch(total, 0, 0);
  cout << result << endl;
  return 0;
}
