#include <bits/stdc++.h>
using namespace std;
long long n, c[100005];
vector<string> vv;
long long dp[100005][2];
long long go(long long i, long long rev) {
  if (i >= n) return 0;
  if (dp[i][rev] != -1) return dp[i][rev];
  long long ans = 1e17;
  string a, b, pichli;
  pichli = vv[i - 1];
  if (rev) reverse((pichli).begin(), (pichli).end());
  a = b = vv[i];
  reverse((b).begin(), (b).end());
  if (a >= pichli) ans = min(ans, go(i + 1, 0));
  long long other = go(i + 1, 1);
  if (other != 1e17) other += c[i];
  if (b >= pichli) ans = min(ans, other);
  return dp[i][rev] = ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long i, j;
  memset(dp, -1, sizeof dp);
  string s;
  cin >> n;
  for (i = 0; i < n; i++) cin >> c[i];
  for (i = 0; i < n; i++) {
    cin >> s;
    vv.push_back(s);
  }
  long long other = go(1, 1);
  if (other != 1e17) other += c[0];
  long long ans = min(go(1, 0), other);
  if (ans == 1e17) {
    cout << -1;
    return 0;
  }
  cout << ans;
  return 0;
}
