#include <bits/stdc++.h>
using namespace std;
string str[100005];
long long n, ara[100005], dp[100005][2];
long long call(int pos, int done) {
  if (pos == n) return 0;
  if (dp[pos][done] != -1) return dp[pos][done];
  long long a = 2e16, b = 2e16;
  string s = str[pos - 1];
  string r = str[pos];
  reverse(r.begin(), r.end());
  if (done) reverse(s.begin(), s.end());
  if (s <= str[pos]) a = call(pos + 1, 0);
  if (s <= r) b = ara[pos] + call(pos + 1, 1);
  return dp[pos][done] = min(a, b);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> ara[i];
  for (int i = 0; i < n; i++) cin >> str[i];
  memset(dp, -1, sizeof(dp));
  long long ans = min(call(1, 0), ara[0] + call(1, 1));
  if (ans == 2e16)
    cout << -1;
  else
    cout << ans;
}
